Date: (Mon) Jun 13, 2016

Introduction:

Data: Source: Training: “https://inclass.kaggle.com/c/can-we-predict-voting-outcomes/download/train2016.csv
New: “https://inclass.kaggle.com/c/can-we-predict-voting-outcomes/download/test2016.csv
Time period:

Synopsis:

Based on analysis utilizing <> techniques, :

Summary of key steps & error improvement stats:

Prediction Accuracy Enhancement Options:

  • transform.data chunk:
    • derive features from multiple features
  • manage.missing.data chunk:
    • Not fill missing vars
    • Fill missing numerics with a different algorithm
    • Fill missing chars with data based on clusters

[](.png)

Potential next steps include:

  • Organization:
    • Categorize by chunk
    • Priority criteria:
      1. Ease of change
      2. Impacts report
      3. Cleans innards
      4. Bug report
  • all chunks:
    • at chunk-end rm(!glb_)
  • manage.missing.data chunk:
    • cleaner way to manage re-splitting of training vs. new entity
  • extract.features chunk:
    • Add n-grams for glbFeatsText
      • “RTextTools”, “tau”, “RWeka”, and “textcat” packages
  • fit.models chunk:
    • Classification: Plot AUC Curves for all models & highlight glbMdlSel
    • Prediction accuracy scatter graph:
    • Add tiles (raw vs. PCA)
    • Use shiny for drop-down of “important” features
    • Use plot.ly for interactive plots ?

    • Change .fit suffix of model metrics to .mdl if it’s data independent (e.g. AIC, Adj.R.Squared - is it truly data independent ?, etc.)
    • create a custom model for rpart that has minbucket as a tuning parameter
    • varImp for randomForest crashes in caret version:6.0.41 -> submit bug report

  • Probability handling for multinomials vs. desired binomial outcome
  • ROCR currently supports only evaluation of binary classification tasks (version 1.0.7)
  • extensions toward multiclass classification are scheduled for the next release

  • fit.all.training chunk:
    • myplot_prediction_classification: displays ‘x’ instead of ‘+’ when there are no prediction errors
  • Compare glb_sel_mdl vs. glb_fin_mdl:
    • varImp
    • Prediction differences (shd be minimal ?)
  • Move glb_analytics_diag_plots to mydsutils.R: (+) Easier to debug (-) Too many glb vars used
  • Add print(ggplot.petrinet(glb_analytics_pn) + coord_flip()) at the end of every major chunk
  • Parameterize glb_analytics_pn
  • Move glb_impute_missing_data to mydsutils.R: (-) Too many glb vars used; glb_<>_df reassigned
  • Do non-glm methods handle interaction terms ?
  • f-score computation for classifiers should be summation across outcomes (not just the desired one ?)
  • Add accuracy computation to glb_dmy_mdl in predict.data.new chunk
  • Why does splitting fit.data.training.all chunk into separate chunks add an overhead of ~30 secs ? It’s not rbind b/c other chunks have lower elapsed time. Is it the number of plots ?
  • Incorporate code chunks in print_sessionInfo
  • Test against
    • projects in github.com/bdanalytics
    • lectures in jhu-datascience track

Analysis:

rm(list = ls())
set.seed(12345)
options(stringsAsFactors = FALSE)
source("~/Dropbox/datascience/R/mycaret.R")
source("~/Dropbox/datascience/R/mypetrinet.R")
source("~/Dropbox/datascience/R/myplclust.R")
source("~/Dropbox/datascience/R/myplot.R")
source("~/Dropbox/datascience/R/myscript.R")
source("~/Dropbox/datascience/R/mytm.R")
if (is.null(knitr::opts_current$get(name = 'label'))) # Running in IDE
    debugSource("~/Dropbox/datascience/R/mydsutils.R") else
    source("~/Dropbox/datascience/R/mydsutils.R")    
## Loading required package: caret
## Loading required package: lattice
# Gather all package requirements here
suppressPackageStartupMessages(require(doMC))
glbCores <- 10 # of cores on machine - 2
registerDoMC(glbCores) 

suppressPackageStartupMessages(require(caret))
require(plyr)
## Loading required package: plyr
require(dplyr)
## Loading required package: dplyr
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:plyr':
## 
##     arrange, count, desc, failwith, id, mutate, rename, summarise,
##     summarize
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
require(knitr)
## Loading required package: knitr
require(stringr)
## Loading required package: stringr
#source("dbgcaret.R")
#packageVersion("snow")
#require(sos); findFn("cosine", maxPages=2, sortby="MaxScore")

# Analysis control global variables
# Inputs
#   url/name = "<PathPointer>"; if url specifies a zip file, name = "<filename>"; 
#               or named collection of <PathPointer>s
#   sep = choose from c(NULL, "\t")
glbObsTrnFile <- list(url = "https://inclass.kaggle.com/c/can-we-predict-voting-outcomes/download/train2016.csv"
    # or list(url = c(NULL, <.inp1> = "<path1>", <.inp2> = "<path2>"))
    #, splitSpecs = list(method = "copy" # default when glbObsNewFile is NULL
    #                       select from c("copy", NULL ???, "condition", "sample", )
    #                      ,nRatio = 0.3 # > 0 && < 1 if method == "sample" 
    #                      ,seed = 123 # any integer or glbObsTrnPartitionSeed if method == "sample" 
    #                      ,condition = # or 'is.na(<var>)'; '<var> <condition_operator> <value>'    
    #                      )
    )                   
 
glbObsNewFile <- list(url = "https://inclass.kaggle.com/c/can-we-predict-voting-outcomes/download/test2016.csv") 

glbObsDropCondition <- #NULL # : default
#   enclose in single-quotes b/c condition might include double qoutes
#       use | & ; NOT || &&    
#   '<condition>' 
    # 'grepl("^First Draft Video:", glbObsAll$Headline)'
    # 'is.na(glbObsAll[, glb_rsp_var_raw])'
    # '(is.na(glbObsAll[, glb_rsp_var_raw]) & grepl("Train", glbObsAll[, glbFeatsId]))'
    # 'is.na(strptime(glbObsAll[, "Date"], glbFeatsDateTime[["Date"]]["format"], tz = glbFeatsDateTime[["Date"]]["timezone"]))'
# '(is.na(glbObsAll[, "Q109244"]) | (glbObsAll[, "Q109244"] != "No"))' # No
'(glbObsAll[, "Q109244"] != "")' # NA
#nrow(do.call("subset",list(glbObsAll, parse(text=paste0("!(", glbObsDropCondition, ")")))))
    
glb_obs_repartition_train_condition <- NULL # : default
#    "<condition>" 

glb_max_fitobs <- NULL # or any integer
glbObsTrnPartitionSeed <- 123 # or any integer
                         
glb_is_regression <- FALSE; glb_is_classification <- !glb_is_regression; 
    glb_is_binomial <- TRUE # or TRUE or FALSE

glb_rsp_var_raw <- "Party"

# for classification, the response variable has to be a factor
glb_rsp_var <- "Party.fctr"

# if the response factor is based on numbers/logicals e.g (0/1 OR TRUE/FALSE vs. "A"/"B"), 
#   or contains spaces (e.g. "Not in Labor Force")
#   caret predict(..., type="prob") crashes
glb_map_rsp_raw_to_var <- #NULL 
function(raw) {
#     return(raw ^ 0.5)
#     return(log(raw))
#     return(log(1 + raw))
#     return(log10(raw)) 
#     return(exp(-raw / 2))
#     
# chk ref value against frequencies vs. alpha sort order
    ret_vals <- rep_len(NA, length(raw)); ret_vals[!is.na(raw)] <- ifelse(raw[!is.na(raw)] == "Republican", "R", "D"); return(relevel(as.factor(ret_vals), ref = "D")) 
    
#     as.factor(paste0("B", raw))
#     as.factor(gsub(" ", "\\.", raw))
    }

#if glb_rsp_var_raw is numeric:
#print(summary(glbObsAll[, glb_rsp_var_raw]))
#glb_map_rsp_raw_to_var(tst <- c(NA, as.numeric(summary(glbObsAll[, glb_rsp_var_raw])))) 

#if glb_rsp_var_raw is character:
#print(table(glbObsAll[, glb_rsp_var_raw], useNA = "ifany"))
# print(table(glb_map_rsp_raw_to_var(tst <- glbObsAll[, glb_rsp_var_raw]), useNA = "ifany"))

glb_map_rsp_var_to_raw <- #NULL 
function(var) {
#     return(var ^ 2.0)
#     return(exp(var))
#     return(10 ^ var) 
#     return(-log(var) * 2)
#     as.numeric(var)
#     levels(var)[as.numeric(var)]
    sapply(levels(var)[as.numeric(var)], function(elm) 
        if (is.na(elm)) return(elm) else
        if (elm == 'R') return("Republican") else
        if (elm == 'D') return("Democrat") else
        stop("glb_map_rsp_var_to_raw: unexpected value: ", elm)
        )  
#     gsub("\\.", " ", levels(var)[as.numeric(var)])
#     c("<=50K", " >50K")[as.numeric(var)]
#     c(FALSE, TRUE)[as.numeric(var)]
}
# print(table(glb_map_rsp_var_to_raw(glb_map_rsp_raw_to_var(tst)), useNA = "ifany"))

if ((glb_rsp_var != glb_rsp_var_raw) && is.null(glb_map_rsp_raw_to_var))
    stop("glb_map_rsp_raw_to_var function expected")

# List info gathered for various columns
# <col_name>:   <description>; <notes>
# USER_ID - an anonymous id unique to a given user
# YOB - the year of birth of the user
# Gender - the gender of the user, either Male or Female
# Income - the household income of the user. Either not provided, or one of "under $25,000", "$25,001 - $50,000", "$50,000 - $74,999", "$75,000 - $100,000", "$100,001 - $150,000", or "over $150,000".
# HouseholdStatus - the household status of the user. Either not provided, or one of "Domestic Partners (no kids)", "Domestic Partners (w/kids)", "Married (no kids)", "Married (w/kids)", "Single (no kids)", or "Single (w/kids)".
# EducationalLevel - the education level of the user. Either not provided, or one of "Current K-12", "High School Diploma", "Current Undergraduate", "Associate's Degree", "Bachelor's Degree", "Master's Degree", or "Doctoral Degree".
# Party - the political party for whom the user intends to vote for. Either "Democrat" or "Republican
# Q124742, Q124122, . . . , Q96024 - 101 different questions that the users were asked on Show of Hands. If the user didn't answer the question, there is a blank. For information about the question text and possible answers, see the file Questions.pdf.

# currently does not handle more than 1 column; consider concatenating multiple columns
# If glbFeatsId == NULL, ".rownames <- as.numeric(row.names())" is the default
glbFeatsId <- "USER_ID" # choose from c(NULL : default, "<id_feat>") 
# glbFeatsCategory <- "Hhold.fctr" # choose from c(NULL : default, "<category_feat>")
glbFeatsCategory <- "Q109244.fctr" # choose from c(NULL : default, "<category_feat>")
# glbFeatsCategory <- "Q115611.fctr" # choose from c(NULL : default, "<category_feat>")

# User-specified exclusions
glbFeatsExclude <- c(NULL
#   Feats that shd be excluded due to known causation by prediction variable
# , "<feat1", "<feat2>"
#   Feats that are factors with unique values (as % of nObs) > 49 (empirically derived)
#   Feats that are linear combinations (alias in glm)
#   Feature-engineering phase -> start by excluding all features except id & category & 
#       work each one in
    , "USER_ID", "YOB", "Gender", "Income", "HouseholdStatus", "EducationLevel" 
    ,"Q124742","Q124122" 
    ,"Q123621","Q123464"
    ,"Q122771","Q122770","Q122769","Q122120"
    ,"Q121700","Q121699","Q121011"
    ,"Q120978","Q120650","Q120472","Q120379","Q120194","Q120014","Q120012" 
    ,"Q119851","Q119650","Q119334"
    ,"Q118892","Q118237","Q118233","Q118232","Q118117"
    ,"Q117193","Q117186"
    ,"Q116797","Q116881","Q116953","Q116601","Q116441","Q116448","Q116197"
    ,"Q115602","Q115777","Q115610","Q115611","Q115899","Q115390","Q115195"
    ,"Q114961","Q114748","Q114517","Q114386","Q114152"
    ,"Q113992","Q113583","Q113584","Q113181"
    ,"Q112478","Q112512","Q112270"
    ,"Q111848","Q111580","Q111220"
    ,"Q110740"
    ,"Q109367","Q109244"
    ,"Q108950","Q108855","Q108617","Q108856","Q108754","Q108342","Q108343"
    ,"Q107869","Q107491"
    ,"Q106993","Q106997","Q106272","Q106388","Q106389","Q106042"
    ,"Q105840","Q105655"
    ,"Q104996"
    ,"Q103293"
    ,"Q102906","Q102674","Q102687","Q102289","Q102089"
    ,"Q101162","Q101163","Q101596"
    ,"Q100689","Q100680","Q100562","Q100010"
    ,"Q99982"
    ,"Q99716"
    ,"Q99581"
    ,"Q99480"
    ,"Q98869"
    ,"Q98578"
    ,"Q98197"
    ,"Q98059","Q98078"
    ,"Q96024" # Done
    ,".pos") 
if (glb_rsp_var_raw != glb_rsp_var)
    glbFeatsExclude <- union(glbFeatsExclude, glb_rsp_var_raw)                    

glbFeatsInteractionOnly <- list()
#glbFeatsInteractionOnly[["<child_feat>"]] <- "<parent_feat>"
glbFeatsInteractionOnly[["YOB.Age.dff"]] <- "YOB.Age.fctr"

glbFeatsDrop <- c(NULL
                # , "<feat1>", "<feat2>"
                )

glb_map_vars <- NULL # or c("<var1>", "<var2>")
glb_map_urls <- list();
# glb_map_urls[["<var1>"]] <- "<var1.url>"

# Derived features; Use this mechanism to cleanse data ??? Cons: Data duplication ???
glbFeatsDerive <- list();

# glbFeatsDerive[["<feat.my.sfx>"]] <- list(
#     mapfn = function(<arg1>, <arg2>) { return(function(<arg1>, <arg2>)) } 
#   , args = c("<arg1>", "<arg2>"))
#myprint_df(data.frame(ImageId = mapfn(glbObsAll$.src, glbObsAll$.pos)))
#data.frame(ImageId = mapfn(glbObsAll$.src, glbObsAll$.pos))[7045:7055, ]

    # character
#     mapfn = function(Education) { raw <- Education; raw[is.na(raw)] <- "NA.my"; return(as.factor(raw)) } 
#     mapfn = function(Week) { return(substr(Week, 1, 10)) }
#     mapfn = function(Name) { return(sapply(Name, function(thsName) 
#                                             str_sub(unlist(str_split(thsName, ","))[1], 1, 1))) } 

#     mapfn = function(descriptor) { return(plyr::revalue(descriptor, c(
#         "ABANDONED BUILDING"  = "OTHER",
#         "**"                  = "**"
#                                           ))) }

#     mapfn = function(description) { mod_raw <- description;
    # This is here because it does not work if it's in txt_map_filename
#         mod_raw <- gsub(paste0(c("\n", "\211", "\235", "\317", "\333"), collapse = "|"), " ", mod_raw)
    # Don't parse for "." because of ".com"; use customized gsub for that text
#         mod_raw <- gsub("(\\w)(!|\\*|,|-|/)(\\w)", "\\1\\2 \\3", mod_raw);
    # Some state acrnoyms need context for separation e.g. 
    #   LA/L.A. could either be "Louisiana" or "LosAngeles"
        # modRaw <- gsub("\\bL\\.A\\.( |,|')", "LosAngeles\\1", modRaw);
    #   OK/O.K. could either be "Oklahoma" or "Okay"
#         modRaw <- gsub("\\bACA OK\\b", "ACA OKay", modRaw); 
#         modRaw <- gsub("\\bNow O\\.K\\.\\b", "Now OKay", modRaw);        
    #   PR/P.R. could either be "PuertoRico" or "Public Relations"        
        # modRaw <- gsub("\\bP\\.R\\. Campaign", "PublicRelations Campaign", modRaw);        
    #   VA/V.A. could either be "Virginia" or "VeteransAdministration"        
        # modRaw <- gsub("\\bthe V\\.A\\.\\:", "the VeteranAffairs:", modRaw);
    #   
    # Custom mods

#         return(mod_raw) }

    # numeric
# Create feature based on record position/id in data   
glbFeatsDerive[[".pos"]] <- list(
    mapfn = function(raw1) { return(1:length(raw1)) }
    , args = c(".rnorm"))
# glbFeatsDerive[[".pos.y"]] <- list(
#     mapfn = function(raw1) { return(1:length(raw1)) }       
#     , args = c(".rnorm"))    

# Add logs of numerics that are not distributed normally
#   Derive & keep multiple transformations of the same feature, if normality is hard to achieve with just one transformation
#   Right skew: logp1; sqrt; ^ 1/3; logp1(logp1); log10; exp(-<feat>/constant)
# glbFeatsDerive[["WordCount.log1p"]] <- list(
#     mapfn = function(WordCount) { return(log1p(WordCount)) } 
#   , args = c("WordCount"))
# glbFeatsDerive[["WordCount.root2"]] <- list(
#     mapfn = function(WordCount) { return(WordCount ^ (1/2)) } 
#   , args = c("WordCount"))
# glbFeatsDerive[["WordCount.nexp"]] <- list(
#     mapfn = function(WordCount) { return(exp(-WordCount)) } 
#   , args = c("WordCount"))
#print(summary(glbObsAll$WordCount))
#print(summary(mapfn(glbObsAll$WordCount)))
    
# If imputation shd be skipped for this feature
# glbFeatsDerive[["District.fctr"]] <- list(
#     mapfn = function(District) {
#         raw <- District;
#         ret_vals <- rep_len("NA", length(raw)); 
#         ret_vals[!is.na(raw)] <- sapply(raw[!is.na(raw)], function(elm) 
#                                         ifelse(elm < 10, "1-9", 
#                                         ifelse(elm < 20, "10-19", "20+")));
#         return(relevel(as.factor(ret_vals), ref = "NA"))
#     }       
#     , args = c("District"))    

# YOB options:
# 1. Missing data:
# 1.1   0 -> Does not improve baseline
# 1.2   Cut factors & "NA" is a level
# 2. Data corrections: < 1928 & > 2000
# 3. Scale YOB
# 4. Add Age
# YOB.Age.fctr needs to be synced with YOB.Age.dff; Create a separate sub-function ???
glbFeatsDerive[["YOB.Age.fctr"]] <- list(
    mapfn = function(raw1) {
        raw <- 2016 - raw1 
        # raw[!is.na(raw) & raw >= 2010] <- NA
        raw[!is.na(raw) & (raw <= 15)] <- NA
        raw[!is.na(raw) & (raw >= 90)] <- NA        
        retVal <- rep_len("NA", length(raw))
        # breaks = c(1879, seq(1949, 1989, 10), 2049)
        # cutVal <- cut(raw[!is.na(raw)], breaks = breaks, 
        #               labels = as.character(breaks + 1)[1:(length(breaks) - 1)])
        cutVal <- cut(raw[!is.na(raw)], breaks = c(15, 20, 25, 30, 35, 40, 50, 65, 90))
        retVal[!is.na(raw)] <- levels(cutVal)[cutVal]
        return(factor(retVal, levels = c("NA"
                ,"(15,20]","(20,25]","(25,30]","(30,35]","(35,40]","(40,50]","(50,65]","(65,90]"),
                        ordered = TRUE))
    }
    , args = c("YOB"))

# YOB.Age.fctr needs to be synced with YOB.Age.dff; Create a separate sub-function ???
glbFeatsDerive[["YOB.Age.dff"]] <- list(
    mapfn = function(raw1) {
        raw <- 2016 - raw1 
        raw[!is.na(raw) & (raw <= 15)] <- NA
        raw[!is.na(raw) & (raw >= 90)] <- NA        
        breaks <- c(15, 20, 25, 30, 35, 40, 50, 65, 90)

        # retVal <- rep_len(0, length(raw))
        stopifnot(sum(!is.na(raw) && (raw <= 15)) == 0)
        stopifnot(sum(!is.na(raw) && (raw >= 90)) == 0) 
        # msk <- !is.na(raw) && (raw > 15) && (raw <= 20); if (sum(msk > 0)) retVal[msk] <- raw[msk] - 15
        # msk <- !is.na(raw) && (raw > 20) && (raw <= 25); if (sum(msk > 0)) retVal[msk] <- raw[msk] - 20
        # msk <- !is.na(raw) && (raw > 25) && (raw <= 30); if (sum(msk > 0)) retVal[msk] <- raw[msk] - 25
        # msk <- !is.na(raw) && (raw > 30) && (raw <= 35); if (sum(msk > 0)) retVal[msk] <- raw[msk] - 30
        # msk <- !is.na(raw) && (raw > 35) && (raw <= 40); if (sum(msk > 0)) retVal[msk] <- raw[msk] - 35
        # msk <- !is.na(raw) && (raw > 40) && (raw <= 50); if (sum(msk > 0)) retVal[msk] <- raw[msk] - 40
        # msk <- !is.na(raw) && (raw > 50) && (raw <= 65); if (sum(msk > 0)) retVal[msk] <- raw[msk] - 50
        # msk <- !is.na(raw) && (raw > 65) && (raw <= 90); if (sum(msk > 0)) retVal[msk] <- raw[msk] - 65

        breaks <- c(15, 20, 25, 30, 35, 40, 50, 65, 90)        
        retVal <- sapply(raw, function(age) {
            if (is.na(age)) return(0) else
            if ((age > 15) && (age <= 20)) return(age - 15) else
            if ((age > 20) && (age <= 25)) return(age - 20) else
            if ((age > 25) && (age <= 30)) return(age - 25) else
            if ((age > 30) && (age <= 35)) return(age - 30) else
            if ((age > 35) && (age <= 40)) return(age - 35) else
            if ((age > 40) && (age <= 50)) return(age - 40) else
            if ((age > 50) && (age <= 65)) return(age - 50) else
            if ((age > 65) && (age <= 90)) return(age - 65)
        })
        
        return(retVal)
    }
    , args = c("YOB"))

glbFeatsDerive[["Gender.fctr"]] <- list(
    mapfn = function(raw1) {
        raw <- raw1
        raw[raw %in% ""] <- "N"
        raw <- gsub("Male"  , "M", raw, fixed = TRUE)
        raw <- gsub("Female", "F", raw, fixed = TRUE)        
        return(relevel(as.factor(raw), ref = "N"))
    }
    , args = c("Gender"))

glbFeatsDerive[["Income.fctr"]] <- list(
    mapfn = function(raw1) { raw <- raw1;
        raw[raw %in% ""] <- "N"
        raw <- gsub("under $25,000"      , "<25K"    , raw, fixed = TRUE)
        raw <- gsub("$25,001 - $50,000"  , "25-50K"  , raw, fixed = TRUE)
        raw <- gsub("$50,000 - $74,999"  , "50-75K"  , raw, fixed = TRUE)
        raw <- gsub("$75,000 - $100,000" , "75-100K" , raw, fixed = TRUE)        
        raw <- gsub("$100,001 - $150,000", "100-150K", raw, fixed = TRUE)
        raw <- gsub("over $150,000"      , ">150K"   , raw, fixed = TRUE)        
        return(factor(raw, levels = c("N","<25K","25-50K","50-75K","75-100K","100-150K",">150K"),
                      ordered = TRUE))
    }
    , args = c("Income"))

glbFeatsDerive[["Hhold.fctr"]] <- list(
    mapfn = function(raw1) { raw <- raw1;
        raw[raw %in% ""] <- "N"
        raw <- gsub("Domestic Partners (no kids)", "PKn", raw, fixed = TRUE)
        raw <- gsub("Domestic Partners (w/kids)" , "PKy", raw, fixed = TRUE)        
        raw <- gsub("Married (no kids)"          , "MKn", raw, fixed = TRUE)
        raw <- gsub("Married (w/kids)"           , "MKy", raw, fixed = TRUE)        
        raw <- gsub("Single (no kids)"           , "SKn", raw, fixed = TRUE)
        raw <- gsub("Single (w/kids)"            , "SKy", raw, fixed = TRUE)        
        return(relevel(as.factor(raw), ref = "N"))
    }
    , args = c("HouseholdStatus"))

glbFeatsDerive[["Edn.fctr"]] <- list(
    mapfn = function(raw1) { raw <- raw1;
        raw[raw %in% ""] <- "N"
        raw <- gsub("Current K-12"         , "K12", raw, fixed = TRUE)
        raw <- gsub("High School Diploma"  , "HSD", raw, fixed = TRUE)        
        raw <- gsub("Current Undergraduate", "CCg", raw, fixed = TRUE)
        raw <- gsub("Associate's Degree"   , "Ast", raw, fixed = TRUE)
        raw <- gsub("Bachelor's Degree"    , "Bcr", raw, fixed = TRUE)        
        raw <- gsub("Master's Degree"      , "Msr", raw, fixed = TRUE)
        raw <- gsub("Doctoral Degree"      , "PhD", raw, fixed = TRUE)        
        return(factor(raw, levels = c("N","K12","HSD","CCg","Ast","Bcr","Msr","PhD"),
                      ordered = TRUE))
    }
    , args = c("EducationLevel"))

# for (qsn in c("Q124742","Q124122"))
# for (qsn in grep("Q12(.{4})(?!\\.fctr)", names(glbObsTrn), value = TRUE, perl = TRUE))
for (qsn in grep("Q", glbFeatsExclude, fixed = TRUE, value = TRUE))    
    glbFeatsDerive[[paste0(qsn, ".fctr")]] <- list(
        mapfn = function(raw1) {
            raw1[raw1 %in% ""] <- "NA"
            rawVal <- unique(raw1)
            
            if (length(setdiff(rawVal, (expVal <- c("NA", "No", "Ys")))) == 0) {
                raw1 <- gsub("Yes", "Ys", raw1, fixed = TRUE)
                if (length(setdiff(rawVal, expVal)) > 0)
                    stop(qsn, " vals: ", paste0(rawVal, collapse = "|"), 
                         " does not match expectation: ", paste0(expVal, collapse = "|"))
            } else
            if (length(setdiff(rawVal, (expVal <- c("NA", "Me", "Circumstances")))) == 0) {
                raw1 <- gsub("Circumstances", "Cs", raw1, fixed = TRUE)
                if (length(setdiff(rawVal, expVal)) > 0)
                    stop(qsn, " vals: ", paste0(rawVal, collapse = "|"), 
                         " does not match expectation: ", paste0(expVal, collapse = "|"))
            } else
            if (length(setdiff(rawVal, (expVal <- c("NA", "Grrr people", "Yay people!")))) == 0) {
                raw1 <- gsub("Grrr people", "Gr", raw1, fixed = TRUE)
                raw1 <- gsub("Yay people!", "Yy", raw1, fixed = TRUE)                
                if (length(setdiff(rawVal, expVal)) > 0)
                    stop(qsn, " vals: ", paste0(rawVal, collapse = "|"), 
                         " does not match expectation: ", paste0(expVal, collapse = "|"))
            } else
            if (length(setdiff(rawVal, (expVal <- c("NA", "Idealist", "Pragmatist")))) == 0) {
                raw1 <- gsub("Idealist"  , "Id", raw1, fixed = TRUE)
                raw1 <- gsub("Pragmatist", "Pr", raw1, fixed = TRUE)                
                if (length(setdiff(rawVal, expVal)) > 0)
                    stop(qsn, " vals: ", paste0(rawVal, collapse = "|"), 
                         " does not match expectation: ", paste0(expVal, collapse = "|"))
            } else
            if (length(setdiff(rawVal, (expVal <- c("NA", "Private", "Public")))) == 0) {
                raw1 <- gsub("Private", "Pt", raw1, fixed = TRUE)
                raw1 <- gsub("Public" , "Pc", raw1, fixed = TRUE)                
                if (length(setdiff(rawVal, expVal)) > 0)
                    stop(qsn, " vals: ", paste0(rawVal, collapse = "|"), 
                         " does not match expectation: ", paste0(expVal, collapse = "|"))
            }
            
            return(relevel(as.factor(raw1), ref = "NA"))
        }
        , args = c(qsn))

# If imputation of missing data is not working ...
# glbFeatsDerive[["FertilityRate.nonNA"]] <- list(
#     mapfn = function(FertilityRate, Region) {
#         RegionMdn <- tapply(FertilityRate, Region, FUN = median, na.rm = TRUE)
# 
#         retVal <- FertilityRate
#         retVal[is.na(FertilityRate)] <- RegionMdn[Region[is.na(FertilityRate)]]
#         return(retVal)
#     }
#     , args = c("FertilityRate", "Region"))
    
#     mapfn = function(HOSPI.COST) { return(cut(HOSPI.COST, 5, breaks = c(0, 100000, 200000, 300000, 900000), labels = NULL)) }     
#     mapfn = function(Rasmussen)  { return(ifelse(sign(Rasmussen) >= 0, 1, 0)) } 
#     mapfn = function(startprice) { return(startprice ^ (1/2)) }       
#     mapfn = function(startprice) { return(log(startprice)) }   
#     mapfn = function(startprice) { return(exp(-startprice / 20)) }
#     mapfn = function(startprice) { return(scale(log(startprice))) }     
#     mapfn = function(startprice) { return(sign(sprice.predict.diff) * (abs(sprice.predict.diff) ^ (1/10))) }        

    # factor      
#     mapfn = function(PropR) { return(as.factor(ifelse(PropR >= 0.5, "Y", "N"))) }
#     mapfn = function(productline, description) { as.factor(gsub(" ", "", productline)) }
#     mapfn = function(purpose) { return(relevel(as.factor(purpose), ref="all_other")) }
#     mapfn = function(raw) { tfr_raw <- as.character(cut(raw, 5)); 
#                             tfr_raw[is.na(tfr_raw)] <- "NA.my";
#                             return(as.factor(tfr_raw)) }
#     mapfn = function(startprice.log10) { return(cut(startprice.log10, 3)) }
#     mapfn = function(startprice.log10) { return(cut(sprice.predict.diff, c(-1000, -100, -10, -1, 0, 1, 10, 100, 1000))) }    

#     , args = c("<arg1>"))
    
    # multiple args
#     mapfn = function(id, date) { return(paste(as.character(id), as.character(date), sep = "#")) }        
#     mapfn = function(PTS, oppPTS) { return(PTS - oppPTS) }
#     mapfn = function(startprice.log10.predict, startprice) {
#                  return(spdiff <- (10 ^ startprice.log10.predict) - startprice) } 
#     mapfn = function(productline, description) { as.factor(
#         paste(gsub(" ", "", productline), as.numeric(nchar(description) > 0), sep = "*")) }
#     mapfn = function(.src, .pos) { 
#         return(paste(.src, sprintf("%04d", 
#                                    ifelse(.src == "Train", .pos, .pos - 7049)
#                                    ), sep = "#")) }       

# # If glbObsAll is not sorted in the desired manner
#     mapfn=function(Week) { return(coredata(lag(zoo(orderBy(~Week, glbObsAll)$ILI), -2, na.pad=TRUE))) }
#     mapfn=function(ILI) { return(coredata(lag(zoo(ILI), -2, na.pad=TRUE))) }
#     mapfn=function(ILI.2.lag) { return(log(ILI.2.lag)) }

# glbFeatsDerive[["<var1>"]] <- glbFeatsDerive[["<var2>"]]

# tst <- "descr.my"; args_lst <- NULL; for (arg in glbFeatsDerive[[tst]]$args) args_lst[[arg]] <- glbObsAll[, arg]; print(head(args_lst[[arg]])); print(head(drv_vals <- do.call(glbFeatsDerive[[tst]]$mapfn, args_lst))); 
# print(which_ix <- which(args_lst[[arg]] == 0.75)); print(drv_vals[which_ix]); 

glbFeatsDateTime <- list()
# Use OlsonNames() to enumerate supported time zones
# glbFeatsDateTime[["<DateTimeFeat>"]] <- 
#     c(format = "%Y-%m-%d %H:%M:%S" or "%m/%e/%y", timezone = "US/Eastern", impute.na = TRUE, 
#       last.ctg = FALSE, poly.ctg = FALSE)

glbFeatsPrice <- NULL # or c("<price_var>")

glbFeatsImage <- list() #list(<imageFeat> = list(patchSize = 10)) # if patchSize not specified, no patch computation

glbFeatsText <- list()
Sys.setlocale("LC_ALL", "C") # For english
## [1] "C/C/C/C/C/en_US.UTF-8"
#glbFeatsText[["<TextFeature>"]] <- list(NULL,
#   ,names = myreplacePunctuation(str_to_lower(gsub(" ", "", c(NULL, 
#       <comma-separated-screened-names>
#   ))))
#   ,rareWords = myreplacePunctuation(str_to_lower(gsub(" ", "", c(NULL, 
#       <comma-separated-nonSCOWL-words>
#   ))))
#)

# Text Processing Step: custom modifications not present in txt_munge -> use glbFeatsDerive
# Text Processing Step: universal modifications
glb_txt_munge_filenames_pfx <- "<projectId>_mytxt_"

# Text Processing Step: tolower
# Text Processing Step: myreplacePunctuation
# Text Processing Step: removeWords
glb_txt_stop_words <- list()
# Remember to use unstemmed words
if (length(glbFeatsText) > 0) {
    require(tm)
    require(stringr)

    glb_txt_stop_words[["<txt_var>"]] <- sort(myreplacePunctuation(str_to_lower(gsub(" ", "", c(NULL
        # Remove any words from stopwords            
#         , setdiff(myreplacePunctuation(stopwords("english")), c("<keep_wrd1>", <keep_wrd2>"))
                                
        # Remove salutations
        ,"mr","mrs","dr","Rev"                                

        # Remove misc
        #,"th" # Happy [[:digit::]]+th birthday 

        # Remove terms present in Trn only or New only; search for "Partition post-stem"
        #   ,<comma-separated-terms>        

        # cor.y.train == NA
#         ,unlist(strsplit(paste(c(NULL
#           ,"<comma-separated-terms>"
#         ), collapse=",")

        # freq == 1; keep c("<comma-separated-terms-to-keep>")
            # ,<comma-separated-terms>

        # chisq.pval high (e.g. == 1); keep c("<comma-separated-terms-to-keep>")
            # ,<comma-separated-terms>

        # nzv.freqRatio high (e.g. >= glbFeatsNzvFreqMax); keep c("<comma-separated-terms-to-keep>")
            # ,<comma-separated-terms>        
                                            )))))
}
#orderBy(~term, glb_post_stem_words_terms_df_lst[[txtFeat]][grep("^man", glb_post_stem_words_terms_df_lst[[txtFeat]]$term), ])
#glbObsAll[glb_post_stem_words_terms_mtrx_lst[[txtFeat]][, 4866] > 0, c(glb_rsp_var, txtFeat)]

# To identify terms with a specific freq
#paste0(sort(subset(glb_post_stop_words_terms_df_lst[[txtFeat]], freq == 1)$term), collapse = ",")
#paste0(sort(subset(glb_post_stem_words_terms_df_lst[[txtFeat]], freq <= 2)$term), collapse = ",")
#subset(glb_post_stem_words_terms_df_lst[[txtFeat]], term %in% c("zinger"))

# To identify terms with a specific freq & 
#   are not stemmed together later OR is value of color.fctr (e.g. gold)
#paste0(sort(subset(glb_post_stop_words_terms_df_lst[[txtFeat]], (freq == 1) & !(term %in% c("blacked","blemish","blocked","blocks","buying","cables","careful","carefully","changed","changing","chargers","cleanly","cleared","connect","connects","connected","contains","cosmetics","default","defaulting","defective","definitely","describe","described","devices","displays","drop","drops","engravement","excellant","excellently","feels","fix","flawlessly","frame","framing","gentle","gold","guarantee","guarantees","handled","handling","having","install","iphone","iphones","keeped","keeps","known","lights","line","lining","liquid","liquidation","looking","lots","manuals","manufacture","minis","most","mostly","network","networks","noted","opening","operated","performance","performs","person","personalized","photograph","physically","placed","places","powering","pre","previously","products","protection","purchasing","returned","rotate","rotation","running","sales","second","seconds","shipped","shuts","sides","skin","skinned","sticker","storing","thats","theres","touching","unusable","update","updates","upgrade","weeks","wrapped","verified","verify") ))$term), collapse = ",")

#print(subset(glb_post_stem_words_terms_df_lst[[txtFeat]], (freq <= 2)))
#glbObsAll[which(terms_mtrx[, 229] > 0), glbFeatsText]

# To identify terms with cor.y == NA
#orderBy(~-freq+term, subset(glb_post_stop_words_terms_df_lst[[txtFeat]], is.na(cor.y)))
#paste(sort(subset(glb_post_stop_words_terms_df_lst[[txtFeat]], is.na(cor.y))[, "term"]), collapse=",")
#orderBy(~-freq+term, subset(glb_post_stem_words_terms_df_lst[[txtFeat]], is.na(cor.y)))

# To identify terms with low cor.y.abs
#head(orderBy(~cor.y.abs+freq+term, subset(glb_post_stem_words_terms_df_lst[[txtFeat]], !is.na(cor.y))), 5)

# To identify terms with high chisq.pval
#subset(glb_post_stem_words_terms_df_lst[[txtFeat]], chisq.pval > 0.99)
#paste0(sort(subset(glb_post_stem_words_terms_df_lst[[txtFeat]], (chisq.pval > 0.99) & (freq <= 10))$term), collapse=",")
#paste0(sort(subset(glb_post_stem_words_terms_df_lst[[txtFeat]], (chisq.pval > 0.9))$term), collapse=",")
#head(orderBy(~-chisq.pval+freq+term, glb_post_stem_words_terms_df_lst[[txtFeat]]), 5)
#glbObsAll[glb_post_stem_words_terms_mtrx_lst[[txtFeat]][, 68] > 0, glbFeatsText]
#orderBy(~term, glb_post_stem_words_terms_df_lst[[txtFeat]][grep("^m", glb_post_stem_words_terms_df_lst[[txtFeat]]$term), ])

# To identify terms with high nzv.freqRatio
#summary(glb_post_stem_words_terms_df_lst[[txtFeat]]$nzv.freqRatio)
#paste0(sort(setdiff(subset(glb_post_stem_words_terms_df_lst[[txtFeat]], (nzv.freqRatio >= glbFeatsNzvFreqMax) & (freq < 10) & (chisq.pval >= 0.05))$term, c( "128gb","3g","4g","gold","ipad1","ipad3","ipad4","ipadair2","ipadmini2","manufactur","spacegray","sprint","tmobil","verizon","wifion"))), collapse=",")

# To identify obs with a txt term
#tail(orderBy(~-freq+term, glb_post_stop_words_terms_df_lst[[txtFeat]]), 20)
#mydspObs(list(descr.my.contains="non"), cols=c("color", "carrier", "cellular", "storage"))
#grep("ever", dimnames(terms_stop_mtrx)$Terms)
#which(terms_stop_mtrx[, grep("ipad", dimnames(terms_stop_mtrx)$Terms)] > 0)
#glbObsAll[which(terms_stop_mtrx[, grep("16", dimnames(terms_stop_mtrx)$Terms)[1]] > 0), c(glbFeatsCategory, "storage", txtFeat)]

# Text Processing Step: screen for names # Move to glbFeatsText specs section in order of text processing steps
# glbFeatsText[["<txtFeat>"]]$names <- myreplacePunctuation(str_to_lower(gsub(" ", "", c(NULL
#         # Person names for names screening
#         ,<comma-separated-list>
#         
#         # Company names
#         ,<comma-separated-list>
#                     
#         # Product names
#         ,<comma-separated-list>
#     ))))

# glbFeatsText[["<txtFeat>"]]$rareWords <- myreplacePunctuation(str_to_lower(gsub(" ", "", c(NULL
#         # Words not in SCOWL db
#         ,<comma-separated-list>
#     ))))

# To identify char vectors post glbFeatsTextMap
#grep("six(.*)hour", glb_txt_chr_lst[[txtFeat]], ignore.case = TRUE, value = TRUE)
#grep("[S|s]ix(.*)[H|h]our", glb_txt_chr_lst[[txtFeat]], value = TRUE)

# To identify whether terms shd be synonyms
#orderBy(~term, glb_post_stop_words_terms_df_lst[[txtFeat]][grep("^moder", glb_post_stop_words_terms_df_lst[[txtFeat]]$term), ])
# term_row_df <- glb_post_stop_words_terms_df_lst[[txtFeat]][grep("^came$", glb_post_stop_words_terms_df_lst[[txtFeat]]$term), ]
# 
# cor(glb_post_stop_words_terms_mtrx_lst[[txtFeat]][glbObsAll$.lcn == "Fit", term_row_df$pos], glbObsTrn[, glb_rsp_var], use="pairwise.complete.obs")

# To identify which stopped words are "close" to a txt term
#sort(glbFeatsCluster)

# Text Processing Step: stemDocument
# To identify stemmed txt terms
#glb_post_stop_words_terms_df_lst[[txtFeat]][grep("^la$", glb_post_stop_words_terms_df_lst[[txtFeat]]$term), ]
#orderBy(~term, glb_post_stem_words_terms_df_lst[[txtFeat]][grep("^con", glb_post_stem_words_terms_df_lst[[txtFeat]]$term), ])
#glbObsAll[which(terms_stem_mtrx[, grep("use", dimnames(terms_stem_mtrx)$Terms)[[1]]] > 0), c(glbFeatsId, "productline", txtFeat)]
#glbObsAll[which(TfIdf_stem_mtrx[, 191] > 0), c(glbFeatsId, glbFeatsCategory, txtFeat)]
#glbObsAll[which(glb_post_stop_words_terms_mtrx_lst[[txtFeat]][, 6165] > 0), c(glbFeatsId, glbFeatsCategory, txtFeat)]
#which(glbObsAll$UniqueID %in% c(11915, 11926, 12198))

# Text Processing Step: mycombineSynonyms
#   To identify which terms are associated with not -> combine "could not" & "couldn't"
#findAssocs(glb_full_DTM_lst[[txtFeat]], "not", 0.05)
#   To identify which synonyms should be combined
#orderBy(~term, glb_post_stem_words_terms_df_lst[[txtFeat]][grep("^c", glb_post_stem_words_terms_df_lst[[txtFeat]]$term), ])
chk_comb_cor <- function(syn_lst) {
#     cor(terms_stem_mtrx[glbObsAll$.src == "Train", grep("^(damag|dent|ding)$", dimnames(terms_stem_mtrx)[[2]])], glbObsTrn[, glb_rsp_var], use="pairwise.complete.obs")
    print(subset(glb_post_stem_words_terms_df_lst[[txtFeat]], term %in% syn_lst$syns))
    print(subset(get_corpus_terms(tm_map(glbFeatsTextCorpus[[txtFeat]], mycombineSynonyms, list(syn_lst), lazy=FALSE)), term == syn_lst$word))
#     cor(terms_stop_mtrx[glbObsAll$.src == "Train", grep("^(damage|dent|ding)$", dimnames(terms_stop_mtrx)[[2]])], glbObsTrn[, glb_rsp_var], use="pairwise.complete.obs")
#     cor(rowSums(terms_stop_mtrx[glbObsAll$.src == "Train", grep("^(damage|dent|ding)$", dimnames(terms_stop_mtrx)[[2]])]), glbObsTrn[, glb_rsp_var], use="pairwise.complete.obs")
}
#chk_comb_cor(syn_lst=list(word="cabl",  syns=c("cabl", "cord")))
#chk_comb_cor(syn_lst=list(word="damag",  syns=c("damag", "dent", "ding")))
#chk_comb_cor(syn_lst=list(word="dent",  syns=c("dent", "ding")))
#chk_comb_cor(syn_lst=list(word="use",  syns=c("use", "usag")))

glbFeatsTextSynonyms <- list()
# list parsed to collect glbFeatsText[[<txtFeat>]]$vldTerms
# glbFeatsTextSynonyms[["Hdln.my"]] <- list(NULL
#     # people in places
#     , list(word = "australia", syns = c("australia", "australian"))
#     , list(word = "italy", syns = c("italy", "Italian"))
#     , list(word = "newyork", syns = c("newyork", "newyorker"))    
#     , list(word = "Pakistan", syns = c("Pakistan", "Pakistani"))    
#     , list(word = "peru", syns = c("peru", "peruvian"))
#     , list(word = "qatar", syns = c("qatar", "qatari"))
#     , list(word = "scotland", syns = c("scotland", "scotish"))
#     , list(word = "Shanghai", syns = c("Shanghai", "Shanzhai"))    
#     , list(word = "venezuela", syns = c("venezuela", "venezuelan"))    
# 
#     # companies - needs to be data dependent 
#     #   - e.g. ensure BNP in this experiment/feat always refers to BNPParibas
#         
#     # general synonyms
#     , list(word = "Create", syns = c("Create","Creator")) 
#     , list(word = "cute", syns = c("cute","cutest"))     
#     , list(word = "Disappear", syns = c("Disappear","Fadeout"))     
#     , list(word = "teach", syns = c("teach", "taught"))     
#     , list(word = "theater",  syns = c("theater", "theatre", "theatres")) 
#     , list(word = "understand",  syns = c("understand", "understood"))    
#     , list(word = "weak",  syns = c("weak", "weaken", "weaker", "weakest"))
#     , list(word = "wealth",  syns = c("wealth", "wealthi"))    
#     
#     # custom synonyms (phrases)
#     
#     # custom synonyms (names)
#                                       )
#glbFeatsTextSynonyms[["<txtFeat>"]] <- list(NULL
#     , list(word="<stem1>",  syns=c("<stem1>", "<stem1_2>"))
#                                       )

for (txtFeat in names(glbFeatsTextSynonyms))
    for (entryIx in 1:length(glbFeatsTextSynonyms[[txtFeat]])) {
        glbFeatsTextSynonyms[[txtFeat]][[entryIx]]$word <-
            str_to_lower(glbFeatsTextSynonyms[[txtFeat]][[entryIx]]$word)
        glbFeatsTextSynonyms[[txtFeat]][[entryIx]]$syns <-
            str_to_lower(glbFeatsTextSynonyms[[txtFeat]][[entryIx]]$syns)        
    }        

glbFeatsTextSeed <- 181
# tm options include: check tm::weightSMART 
glb_txt_terms_control <- list( # Gather model performance & run-time stats
                    # weighting = function(x) weightSMART(x, spec = "nnn")
                    # weighting = function(x) weightSMART(x, spec = "lnn")
                    # weighting = function(x) weightSMART(x, spec = "ann")
                    # weighting = function(x) weightSMART(x, spec = "bnn")
                    # weighting = function(x) weightSMART(x, spec = "Lnn")
                    # 
                    weighting = function(x) weightSMART(x, spec = "ltn") # default
                    # weighting = function(x) weightSMART(x, spec = "lpn")                    
                    # 
                    # weighting = function(x) weightSMART(x, spec = "ltc")                    
                    # 
                    # weighting = weightBin 
                    # weighting = weightTf 
                    # weighting = weightTfIdf # : default
                # termFreq selection criteria across obs: tm default: list(global=c(1, Inf))
                    , bounds = list(global = c(1, Inf)) 
                # wordLengths selection criteria: tm default: c(3, Inf)
                    , wordLengths = c(1, Inf) 
                              ) 

glb_txt_cor_var <- glb_rsp_var # : default # or c(<feat>)

# select one from c("union.top.val.cor", "top.cor", "top.val", default: "top.chisq", "sparse")
glbFeatsTextFilter <- "top.chisq" 
glbFeatsTextTermsMax <- rep(10, length(glbFeatsText)) # :default
names(glbFeatsTextTermsMax) <- names(glbFeatsText)

# Text Processing Step: extractAssoc
glbFeatsTextAssocCor <- rep(1, length(glbFeatsText)) # :default 
names(glbFeatsTextAssocCor) <- names(glbFeatsText)

# Remember to use stemmed terms
glb_important_terms <- list()

# Text Processing Step: extractPatterns (ngrams)
glbFeatsTextPatterns <- list()
#glbFeatsTextPatterns[[<txtFeat>>]] <- list()
#glbFeatsTextPatterns[[<txtFeat>>]] <- c(metropolitan.diary.colon = "Metropolitan Diary:")

# Have to set it even if it is not used
# Properties:
#   numrows(glb_feats_df) << numrows(glbObsFit
#   Select terms that appear in at least 0.2 * O(FP/FN(glbObsOOB)) ???
#       numrows(glbObsOOB) = 1.1 * numrows(glbObsNew) ???
glb_sprs_thresholds <- NULL # or c(<txtFeat1> = 0.988, <txtFeat2> = 0.970, <txtFeat3> = 0.970)

glbFctrMaxUniqVals <- 20 # default: 20
glb_impute_na_data <- FALSE # or TRUE
glb_mice_complete.seed <- 144 # or any integer

glbFeatsCluster <- paste(grep("^Q.", glbFeatsExclude, value = TRUE), "fctr", sep = ".") # NULL : glbFeatsCluster <- c("YOB.Age.fctr", "Gender.fctr", "Income.fctr", 
                     # # "Hhold.fctr",
                     # "Edn.fctr",
                     # paste(grep("^Q.", glbFeatsExclude, value = TRUE), "fctr", sep = ".")) # NULL : default or c("<feat1>", "<feat2>")
# glbFeatsCluster <- grep(paste0("[", 
#                         toupper(paste0(substr(glbFeatsText, 1, 1), collapse = "")),
#                                       "]\\.[PT]\\."), 
#                                names(glbObsAll), value = TRUE)

glb_cluster.seed <- 189 # or any integer
glbClusterEntropyVar <- NULL # c(glb_rsp_var, as.factor(cut(glb_rsp_var, 3)), default: NULL)
glbFeatsClusterVarsExclude <- FALSE # default FALSE

glb_interaction_only_feats <- NULL # : default or c(<parent_feat> = "<child_feat>")

glbFeatsNzvFreqMax <- 19 # 19 : caret default
glbFeatsNzvUniqMin <- 10 # 10 : caret default

glbRFESizes <- list()
#glbRFESizes[["mdlFamily"]] <- c(4, 8, 16, 32, 64, 67, 68, 69) # Accuracy@69/70 = 0.8258
# glbRFESizes[["RFE.X"]] <- c(2, 3, 4, 5, 6, 7, 8, 16, 32, 64, 128, 247) # accuracy(5) = 0.6154
# glbRFESizes[["Final"]] <- c(8, 16, 32, 40, 44, 46, 48, 49, 50, 51, 52, 56, 64, 96, 128, 247) # accuracy(49) = 0.6164

glbRFEResults <- NULL

glbObsFitOutliers <- list()
# If outliers.n >= 10; consider concatenation of interaction vars
# glbObsFitOutliers[["<mdlFamily>"]] <- c(NULL
#     is.na(.rstudent)
#     max(.rstudent)
#     is.na(.dffits)
#     .hatvalues >= 0.99        
#     -38,167,642 < minmax(.rstudent) < 49,649,823    
#     , <comma-separated-<glbFeatsId>>
#                                     )
glbObsTrnOutliers <- list()
glbObsTrnOutliers[["Final"]] <- union(glbObsFitOutliers[["All.X"]],
                                c(NULL
                                ))

# Modify mdlId to (build & extract) "<FamilyId>#<Fit|Trn>#<caretMethod>#<preProc1.preProc2>#<samplingMethod>"
glb_models_lst <- list(); glb_models_df <- data.frame()

# Add xgboost algorithm

# Regression
if (glb_is_regression) {
    glbMdlMethods <- c(NULL
        # deterministic
            #, "lm", # same as glm
            , "glm", "bayesglm", "glmnet"
            , "rpart"
        # non-deterministic
            , "gbm", "rf" 
        # Unknown
            , "nnet" , "avNNet" # runs 25 models per cv sample for tunelength=5
            , "svmLinear", "svmLinear2"
            , "svmPoly" # runs 75 models per cv sample for tunelength=5
            , "svmRadial" 
            , "earth"
            , "bagEarth" # Takes a long time
            ,"xgbLinear","xgbTree"
        )
} else
# Classification - Add ada (auto feature selection)
    if (glb_is_binomial)
        glbMdlMethods <- c(NULL
        # deterministic                     
            , "bagEarth" # Takes a long time        
            , "glm", "bayesglm", "glmnet"
            , "nnet"
            , "rpart"
        # non-deterministic        
            , "gbm"
            , "avNNet" # runs 25 models per cv sample for tunelength=5      
            , "rf"
        # Unknown
            , "lda", "lda2"
                # svm models crash when predict is called -> internal to kernlab it should call predict without .outcome
            , "svmLinear", "svmLinear2"
            , "svmPoly" # runs 75 models per cv sample for tunelength=5
            , "svmRadial" 
            , "earth"
            ,"xgbLinear","xgbTree"
        ) else
        glbMdlMethods <- c(NULL
        # deterministic
            ,"glmnet"
        # non-deterministic 
            ,"rf"       
        # Unknown
            ,"gbm","rpart","xgbLinear","xgbTree"
        )

glbMdlFamilies <- list(); glb_mdl_feats_lst <- list()
# family: Choose from c("RFE.X", "Csm.X", "All.X", "Best.Interact") %*% c(NUll, ".NOr", ".Inc")
#   RFE = "Recursive Feature Elimination"
#   Csm = CuStoM
#   NOr = No OutlieRs
#   Inc = INteraCt
#   methods: Choose from c(NULL, <method>, glbMdlMethods) 
#glbMdlFamilies[["RFE.X"]] <- c("glmnet", "glm") # non-NULL vector is mandatory
if (glb_is_classification && !glb_is_binomial) {
    # glm does not work for multinomial
    glbMdlFamilies[["All.X"]] <- c("glmnet") 
} else {
    # glbMdlFamilies[["All.X"]] <- c("glmnet", "glm")
    glbMdlFamilies[["All.X"]] <- c("glmnet")
    # glbMdlFamilies[["RFE.X"]] <- c("glmnet", "glm")
    # glbMdlFamilies[["RFE.X"]] <- c("glmnet")    
    # glbMdlFamilies[["RFE.X"]] <- setdiff(glbMdlMethods, c(NULL
    #     # , "bayesglm" # error: Error in trControl$classProbs && any(classLevels != make.names(classLevels)) : invalid 'x' type in 'x && y'
    #     # , "lda","lda2" # error: Error in lda.default(x, grouping, ...) : variable 236 appears to be constant within groups
    #     , "svmLinear" # Error in .local(object, ...) : test vector does not match model ! In addition: Warning messages:
    #     , "svmLinear2" # SVM has not been trained using `probability = TRUE`, probabilities not available for predictions
    #     , "svmPoly" # runs 75 models per cv sample for tunelength=5 # took > 2 hrs # Error in .local(object, ...) : test vector does not match model !
    #     , "svmRadial" # Error in .local(object, ...) : test vector does not match model !
    #     ,"xgbLinear","xgbTree" # Need clang-omp compiler; Upgrade to Revolution R 3.2.3 (3.2.2 current); https://github.com/dmlc/xgboost/issues/276 thread
    #                                     ))
}
# glbMdlFamilies[["All.X.Inc"]] <- glbMdlFamilies[["All.X"]] # value not used
# glbMdlFamilies[["RFE.X.Inc"]] <- glbMdlFamilies[["RFE.X"]] # value not used

# Check if interaction features make RFE better
# glbMdlFamilies[["CSM.X"]] <- setdiff(glbMdlMethods, c("lda", "lda2")) # crashing due to category:.clusterid ??? #c("glmnet", "glm") # non-NULL list is mandatory
# glb_mdl_feats_lst[["CSM.X"]] <- c(NULL
#     , <comma-separated-features-vector>
#                                   )
# dAFeats.CSM.X %<d-% c(NULL
#     # Interaction feats up to varImp(RFE.X.glmnet) >= 50
#     , <comma-separated-features-vector>
#     , setdiff(myextract_actual_feats(predictors(glbRFEResults)), c(NULL
#                , <comma-separated-features-vector>
#                                                                       ))    
#                                   )
# glb_mdl_feats_lst[["CSM.X"]] <- "%<d-% dAFeats.CSM.X"

# glbMdlFamilies[["Final"]] <- c(NULL) # NULL vector acceptable # c("glmnet", "glm")

glbMdlAllowParallel <- list()
#glbMdlAllowParallel[["Final##rcv#glmnet"]] <- FALSE

# Check if tuning parameters make fit better; make it mdlFamily customizable ?
glbMdlTuneParams <- data.frame()

# When glmnet crashes at model$grid with error: ???
# AllX__rcv_glmnetTuneParams <- rbind(data.frame()
#     ,data.frame(parameter = "alpha",  vals = "0.100 0.325 0.550 0.775 1.000")
#     ,data.frame(parameter = "lambda", vals = "0.05 0.06367626 0.07 0.08 0.09167068")
#                         ) # max.Accuracy.OOB = 0.6020202 @ 0.55 0.03

# glbMdlTuneParams <- rbind(glbMdlTuneParams
#     ,cbind(data.frame(mdlId = "All.X##rcv#glmnet"),            AllX__rcv_glmnetTuneParams)
# )

    #avNNet    
    #   size=[1] 3 5 7 9; decay=[0] 1e-04 0.001  0.01   0.1; bag=[FALSE]; RMSE=1.3300906 

    #bagEarth
    #   degree=1 [2] 3; nprune=64 128 256 512 [1024]; RMSE=0.6486663 (up)
# bagEarthTuneParams <- rbind(data.frame()
#                         ,data.frame(parameter = "degree", vals = "1")
#                         ,data.frame(parameter = "nprune", vals = "256")
#                         )
# glbMdlTuneParams <- myrbind_df(glbMdlTuneParams,
#                                cbind(data.frame(mdlId = "Final.RFE.X.Inc##rcv#bagEarth"),
#                                      bagEarthTuneParams))

# glbMdlTuneParams <- myrbind_df(glbMdlTuneParams, rbind(data.frame()
#     ,data.frame(method = "bagEarth", parameter = "nprune", vals = "256")
#     ,data.frame(method = "bagEarth", parameter = "degree", vals = "2")    
# ))

    #earth 
    #   degree=[1]; nprune=2  [9] 17 25 33; RMSE=0.1334478
    
    #gbm 
    #   shrinkage=0.05 [0.10] 0.15 0.20 0.25; n.trees=100 150 200 [250] 300; interaction.depth=[1] 2 3 4 5; n.minobsinnode=[10]; RMSE=0.2008313     
# glbMdlTuneParams <- myrbind_df(glbMdlTuneParams, rbind(data.frame()
#     ,data.frame(method = "gbm", parameter = "shrinkage", min = 0.05, max = 0.25, by = 0.05)
#     ,data.frame(method = "gbm", parameter = "n.trees", min = 100, max = 300, by = 50)
#     ,data.frame(method = "gbm", parameter = "interaction.depth", min = 1, max = 5, by = 1)
#     ,data.frame(method = "gbm", parameter = "n.minobsinnode", min = 10, max = 10, by = 10)
#     #seq(from=0.05,  to=0.25, by=0.05)
# ))

    #glmnet
    #   alpha=0.100 [0.325] 0.550 0.775 1.000; lambda=0.0005232693 0.0024288010 0.0112734954 [0.0523269304] 0.2428800957; RMSE=0.6164891
# glbMdlTuneParams <- myrbind_df(glbMdlTuneParams, rbind(data.frame()
#     ,data.frame(method = "glmnet", parameter = "alpha", vals = "0.550 0.775 0.8875 0.94375 1.000")
#     ,data.frame(method = "glmnet", parameter = "lambda", vals = "9.858855e-05 0.0001971771 0.0009152152 0.0042480525 0.0197177130")    
# ))

    #nnet    
    #   size=3 5 [7] 9 11; decay=0.0001 0.001 0.01 [0.1] 0.2; RMSE=0.9287422
# glbMdlTuneParams <- myrbind_df(glbMdlTuneParams, rbind(data.frame()
#     ,data.frame(method = "nnet", parameter = "size", vals = "3 5 7 9 11")
#     ,data.frame(method = "nnet", parameter = "decay", vals = "0.0001 0.0010 0.0100 0.1000 0.2000")    
# ))

    #rf # Don't bother; results are not deterministic
    #       mtry=2  35  68 [101] 134; RMSE=0.1339974
# glbMdlTuneParams <- myrbind_df(glbMdlTuneParams, rbind(data.frame()
#     ,data.frame(method = "rf", parameter = "mtry", vals = "2 5 9 13 17")
# ))

    #rpart 
    #   cp=0.020 [0.025] 0.030 0.035 0.040; RMSE=0.1770237
# glbMdlTuneParams <- myrbind_df(glbMdlTuneParams, rbind(data.frame()    
#     ,data.frame(method = "rpart", parameter = "cp", vals = "0.004347826 0.008695652 0.017391304 0.021739130 0.034782609")
# ))
    
    #svmLinear
    #   C=0.01 0.05 [0.10] 0.50 1.00 2.00 3.00 4.00; RMSE=0.1271318; 0.1296718
# glbMdlTuneParams <- myrbind_df(glbMdlTuneParams, rbind(data.frame()
#     ,data.frame(method = "svmLinear", parameter = "C", vals = "0.01 0.05 0.1 0.5 1")
# ))

    #svmLinear2    
    #   cost=0.0625 0.1250 [0.25] 0.50 1.00; RMSE=0.1276354 
# glbMdlTuneParams <- myrbind_df(glbMdlTuneParams, rbind(data.frame()
#     ,data.frame(method = "svmLinear2", parameter = "cost", vals = "0.0625 0.125 0.25 0.5 1")
# ))

    #svmPoly    
    #   degree=[1] 2 3 4 5; scale=0.01 0.05 [0.1] 0.5 1; C=0.50 1.00 [2.00] 3.00 4.00; RMSE=0.1276130
# glbMdlTuneParams <- myrbind_df(glbMdlTuneParams, rbind(data.frame()
#     ,data.frame(method="svmPoly", parameter="degree", min=1, max=5, by=1) #seq(1, 5, 1)
#     ,data.frame(method="svmPoly", parameter="scale", vals="0.01, 0.05, 0.1, 0.5, 1")
#     ,data.frame(method="svmPoly", parameter="C", vals="0.50, 1.00, 2.00, 3.00, 4.00")    
# ))

    #svmRadial
    #   sigma=[0.08674323]; C=0.25 0.50 1.00 [2.00] 4.00; RMSE=0.1614957
    
#glb2Sav(); all.equal(sav_models_df, glb_models_df)

pkgPreprocMethods <-     
# caret version: 6.0.068 # packageVersion("caret")
# operations are applied in this order: zero-variance filter, near-zero variance filter, Box-Cox/Yeo-Johnson/exponential transformation, centering, scaling, range, imputation, PCA, ICA then spatial sign
# *Impute methods needed only if NAs are fed to myfit_mdl
#   Also, ordered.factor in caret creates features as Edn.fctr^4 which is treated as an exponent by bagImpute
    c(NULL
      ,"zv", "nzv"
      ,"BoxCox", "YeoJohnson", "expoTrans"
      ,"center", "scale", "center.scale", "range"
      ,"knnImpute", "bagImpute", "medianImpute"
      ,"zv.pca", "ica", "spatialSign"
      ,"conditionalX") 

glbMdlPreprocMethods <- list(NULL# NULL # : default
    # ,"All.X" = list("glmnet" = union(setdiff(pkgPreprocMethods,
    #                                         c("knnImpute", "bagImpute", "medianImpute")),
    #                                 # c(NULL)))
    #                                 c("zv.pca.spatialSign")))
    # ,"RFE.X" = list("glmnet" = union(setdiff(pkgPreprocMethods,
    #                                         c("knnImpute", "bagImpute", "medianImpute")),
    #                                 c(NULL)))
    #                                 # c("zv.pca.spatialSign")))
)
# glbMdlPreprocMethods[["RFE.X"]] <- list("glmnet" = union(unlist(glbMdlPreprocMethods[["All.X"]]),
#                                                     "nzv.pca.spatialSign"))

# Baseline prediction model feature(s)
glb_Baseline_mdl_var <- NULL # or c("<feat>")

glbMdlMetric_terms <- NULL # or matrix(c(
#                               0,1,2,3,4,
#                               2,0,1,2,3,
#                               4,2,0,1,2,
#                               6,4,2,0,1,
#                               8,6,4,2,0
#                           ), byrow=TRUE, nrow=5)
glbMdlMetricSummary <- NULL # or "<metric_name>"
glbMdlMetricMaximize <- NULL # or FALSE (TRUE is not the default for both classification & regression) 
glbMdlMetricSummaryFn <- NULL # or function(data, lev=NULL, model=NULL) {
#     confusion_mtrx <- t(as.matrix(confusionMatrix(data$pred, data$obs)))
#     #print(confusion_mtrx)
#     #print(confusion_mtrx * glbMdlMetric_terms)
#     metric <- sum(confusion_mtrx * glbMdlMetric_terms) / nrow(data)
#     names(metric) <- glbMdlMetricSummary
#     return(metric)
# }

glbMdlCheckRcv <- FALSE # Turn it on when needed; otherwise takes long time
glb_rcv_n_folds <- 3 # or NULL
glb_rcv_n_repeats <- 3 # or NULL

glb_clf_proba_threshold <- NULL # 0.5

# Model selection criteria
if (glb_is_regression)
    glbMdlMetricsEval <- c("min.RMSE.OOB", "max.R.sq.OOB", "min.elapsedtime.everything",
                           "max.Adj.R.sq.fit", "min.RMSE.fit")
    #glbMdlMetricsEval <- c("min.RMSE.fit", "max.R.sq.fit", "max.Adj.R.sq.fit")    
if (glb_is_classification) {
    if (glb_is_binomial)
        glbMdlMetricsEval <- 
            c("max.Accuracy.OOB", "max.AUCROCR.OOB", "max.AUCpROC.OOB",
              "min.elapsedtime.everything", 
              # "min.aic.fit", 
              "max.Accuracy.fit") else        
        glbMdlMetricsEval <- c("max.Accuracy.OOB", "max.Kappa.OOB", "min.elapsedtime.everything")
}

# select from NULL [no ensemble models], "auto" [all models better than MFO or Baseline], c(mdl_ids in glb_models_lst) [Typically top-rated models in auto]
glbMdlEnsemble <- NULL # NULL : default #"auto"
#     "%<d-% setdiff(mygetEnsembleAutoMdlIds(), 'CSM.X.rf')" 
#     c(<comma-separated-mdlIds>
#      )
glbMdlEnsembleSampleMethods <- c("boot", "boot632", "cv", "repeatedcv"
               # , "LOOCV" # tuneLength * nrow(fitDF) # way too many models
               , "LGOCV"
               , "adaptive_cv" # crashed for Q109244No
               # , "adaptive_boot"  #error: adaptive$min should be less than 3
               # , "adaptive_LGOCV" #error: adaptive$min should be less than 3
               )


# Only for classifications; for regressions remove "(.*)\\.prob" form the regex
# tmp_fitobs_df <- glbObsFit[, grep(paste0("^", gsub(".", "\\.", mygetPredictIds$value, fixed = TRUE), "CSM\\.X\\.(.*)\\.prob"), names(glbObsFit), value = TRUE)]; cor_mtrx <- cor(tmp_fitobs_df); cor_vctr <- sort(cor_mtrx[row.names(orderBy(~-Overall, varImp(glb_models_lst[["Ensemble.repeatedcv.glmnet"]])$imp))[1], ]); summary(cor_vctr); cor_vctr
#ntv.glm <- glm(reformulate(indepVar, glb_rsp_var), family = "binomial", data = glbObsFit)
#step.glm <- step(ntv.glm)

glbMdlSelId <- NULL #select from c(NULL, "All.X##rcv#glmnet", "RFE.X##rcv#glmnet", <mdlId>)
glbMdlFinId <- NULL #select from c(NULL, glbMdlSelId)

glb_dsp_cols <- c(".pos", glbFeatsId, glbFeatsCategory, glb_rsp_var
#               List critical cols excl. above
                  )

# Output specs
# lclgetfltout_df <- function(obsOutFinDf) {
#     require(tidyr)
#     obsOutFinDf <- obsOutFinDf %>%
#         tidyr::separate("ImageId.x.y", c(".src", ".pos", "x", "y"), 
#                         sep = "#", remove = TRUE, extra = "merge")
#     # mnm prefix stands for max_n_mean
#     mnmout_df <- obsOutFinDf %>%
#         dplyr::group_by(.pos) %>%
#         #dplyr::top_n(1, Probability1) %>% # Score = 3.9426         
#         #dplyr::top_n(2, Probability1) %>% # Score = ???; weighted = 3.94254;         
#         #dplyr::top_n(3, Probability1) %>% # Score = 3.9418; weighted = 3.94169; 
#         dplyr::top_n(4, Probability1) %>% # Score = ???; weighted = 3.94149;        
#         #dplyr::top_n(5, Probability1) %>% # Score = 3.9421; weighted = 3.94178
#     
#         # dplyr::summarize(xMeanN = mean(as.numeric(x)), yMeanN = mean(as.numeric(y)))
#         # dplyr::summarize(xMeanN = weighted.mean(as.numeric(x), Probability1), yMeanN = mean(as.numeric(y)))
#         # dplyr::summarize(xMeanN = weighted.mean(as.numeric(x), c(Probability1, 0.2357323, 0.2336925)), yMeanN = mean(as.numeric(y)))    
#         # dplyr::summarize(xMeanN = weighted.mean(as.numeric(x), c(Probability1)), yMeanN = mean(as.numeric(y)))
#         dplyr::summarize(xMeanN = weighted.mean(as.numeric(x), c(Probability1)), 
#                          yMeanN = weighted.mean(as.numeric(y), c(Probability1)))  
#     
#     maxout_df <- obsOutFinDf %>%
#         dplyr::group_by(.pos) %>%
#         dplyr::summarize(maxProb1 = max(Probability1))
#     fltout_df <- merge(maxout_df, obsOutFinDf, 
#                        by.x = c(".pos", "maxProb1"), by.y = c(".pos", "Probability1"),
#                        all.x = TRUE)
#     fmnout_df <- merge(fltout_df, mnmout_df, 
#                        by.x = c(".pos"), by.y = c(".pos"),
#                        all.x = TRUE)
#     return(fmnout_df)
# }
glbObsOut <- list(NULL
        # glbFeatsId will be the first output column, by default
        ,vars = list()
#         ,mapFn = function(obsOutFinDf) {
#                   }
                  )
#obsOutFinDf <- savobsOutFinDf
# glbObsOut$mapFn <- function(obsOutFinDf) {
#     txfout_df <- dplyr::select(obsOutFinDf, -.pos.y) %>%
#         dplyr::mutate(
#             lunch     = levels(glbObsTrn[, "lunch"    ])[
#                        round(mean(as.numeric(glbObsTrn[, "lunch"    ])), 0)],
#             dinner    = levels(glbObsTrn[, "dinner"   ])[
#                        round(mean(as.numeric(glbObsTrn[, "dinner"   ])), 0)],
#             reserve   = levels(glbObsTrn[, "reserve"  ])[
#                        round(mean(as.numeric(glbObsTrn[, "reserve"  ])), 0)],
#             outdoor   = levels(glbObsTrn[, "outdoor"  ])[
#                        round(mean(as.numeric(glbObsTrn[, "outdoor"  ])), 0)],
#             expensive = levels(glbObsTrn[, "expensive"])[
#                        round(mean(as.numeric(glbObsTrn[, "expensive"])), 0)],
#             liquor    = levels(glbObsTrn[, "liquor"   ])[
#                        round(mean(as.numeric(glbObsTrn[, "liquor"   ])), 0)],
#             table     = levels(glbObsTrn[, "table"    ])[
#                        round(mean(as.numeric(glbObsTrn[, "table"    ])), 0)],
#             classy    = levels(glbObsTrn[, "classy"   ])[
#                        round(mean(as.numeric(glbObsTrn[, "classy"   ])), 0)],
#             kids      = levels(glbObsTrn[, "kids"     ])[
#                        round(mean(as.numeric(glbObsTrn[, "kids"     ])), 0)]
#                       )
#     
#     print("ObsNew output class tables:")
#     print(sapply(c("lunch","dinner","reserve","outdoor",
#                    "expensive","liquor","table",
#                    "classy","kids"), 
#                  function(feat) table(txfout_df[, feat], useNA = "ifany")))
#     
#     txfout_df <- txfout_df %>%
#         dplyr::mutate(labels = "") %>%
#         dplyr::mutate(labels = 
#     ifelse(lunch     != "-1", paste(labels, lunch    ), labels)) %>%
#         dplyr::mutate(labels = 
#     ifelse(dinner    != "-1", paste(labels, dinner   ), labels)) %>%
#         dplyr::mutate(labels = 
#     ifelse(reserve   != "-1", paste(labels, reserve  ), labels)) %>%
#         dplyr::mutate(labels = 
#     ifelse(outdoor   != "-1", paste(labels, outdoor  ), labels)) %>%
#         dplyr::mutate(labels =         
#     ifelse(expensive != "-1", paste(labels, expensive), labels)) %>%
#         dplyr::mutate(labels =         
#     ifelse(liquor    != "-1", paste(labels, liquor   ), labels)) %>%
#         dplyr::mutate(labels =         
#     ifelse(table     != "-1", paste(labels, table    ), labels)) %>%
#         dplyr::mutate(labels =         
#     ifelse(classy    != "-1", paste(labels, classy   ), labels)) %>%
#         dplyr::mutate(labels =         
#     ifelse(kids      != "-1", paste(labels, kids     ), labels)) %>%
#         dplyr::select(business_id, labels)
#     return(txfout_df)
# }
#if (!is.null(glbObsOut$mapFn)) obsOutFinDf <- glbObsOut$mapFn(obsOutFinDf); print(head(obsOutFinDf))

glb_out_obs <- NULL # select from c(NULL : default to "new", "all", "new", "trn")

if (glb_is_classification && glb_is_binomial) {
    # glbObsOut$vars[["Probability1"]] <- 
    #     "%<d-% glbObsNew[, mygetPredictIds(glb_rsp_var, glbMdlFinId)$prob]" 
    # glbObsOut$vars[[glb_rsp_var_raw]] <-
    #     "%<d-% glb_map_rsp_var_to_raw(glbObsNew[,
    #                                         mygetPredictIds(glb_rsp_var, glbMdlFinId)$value])"
    glbObsOut$vars[["Predictions"]] <-
        "%<d-% glb_map_rsp_var_to_raw(glbObsNew[,
                                            mygetPredictIds(glb_rsp_var, glbMdlFinId)$value])"
} else {
#     glbObsOut$vars[[glbFeatsId]] <- 
#         "%<d-% as.integer(gsub('Test#', '', glbObsNew[, glbFeatsId]))"
    glbObsOut$vars[[glb_rsp_var]] <- 
        "%<d-% glbObsNew[, mygetPredictIds(glb_rsp_var, glbMdlFinId)$value]"
#     for (outVar in setdiff(glbFeatsExcludeLcl, glb_rsp_var_raw))
#         glbObsOut$vars[[outVar]] <- 
#             paste0("%<d-% mean(glbObsAll[, \"", outVar, "\"], na.rm = TRUE)")
}    
# glbObsOut$vars[[glb_rsp_var_raw]] <- glb_rsp_var_raw
# glbObsOut$vars[[paste0(head(unlist(strsplit(mygetPredictIds$value, "")), -1), collapse = "")]] <-

glbOutStackFnames <- # NULL #: default
    c("Q109244No_AllXpreProc_cnk03_rest_out_fin.csv") 
    # c("Votes_Ensemble_cnk06_out_fin.csv") 


glbOut <- list(pfx = "Q109244NA_AllX_")
# lclImageSampleSeed <- 129
glbOutDataVizFname <- NULL # choose from c(NULL, "<projectId>_obsall.csv")


glbChunks <- list(labels = c("set_global_options_wd","set_global_options"
    ,"import.data","inspect.data","scrub.data","transform.data"
    ,"extract.features"
        ,"extract.features.datetime","extract.features.image","extract.features.price"
        ,"extract.features.text","extract.features.string"  
        ,"extract.features.end"
    ,"manage.missing.data","cluster.data","partition.data.training","select.features"
    ,"fit.models_0","fit.models_1","fit.models_2","fit.models_3"
    ,"fit.data.training_0","fit.data.training_1"
    ,"predict.data.new"         
    ,"display.session.info"))
# To ensure that all chunks in this script are in glbChunks
if (!is.null(chkChunksLabels <- knitr::all_labels()) && # knitr::all_labels() doesn't work in console runs
    !identical(chkChunksLabels, glbChunks$labels)) {
    print(sprintf("setdiff(chkChunksLabels, glbChunks$labels): %s", 
                  setdiff(chkChunksLabels, glbChunks$labels)))    
    print(sprintf("setdiff(glbChunks$labels, chkChunksLabels): %s", 
                  setdiff(glbChunks$labels, chkChunksLabels)))    
}

glbChunks[["first"]] <- NULL # NULL # default: script will load envir from previous chunk
glbChunks[["last" ]] <- NULL # default: script will save envir at end of this chunk 
glbChunks[["inpFilePathName"]] <- NULL #"data/Q109244No_AllXNOr_cnk01_fit.models_1_fit.models_1.RData" # NULL: default or "data/<prvScriptName>_<lstChunkLbl>.RData"
#mysavChunk(glbOut$pfx, glbChunks[["last"]]) # called from myevlChunk
# Temporary: Delete this function (if any) from here after appropriate .RData file is saved

# Inspect max OOB FP
#chkObsOOB <- subset(glbObsOOB, !label.fctr.All.X..rcv.glmnet.is.acc)
#chkObsOOBFP <- subset(chkObsOOB, label.fctr.All.X..rcv.glmnet == "left_eye_center") %>% dplyr::mutate(Probability1 = label.fctr.All.X..rcv.glmnet.prob) %>% select(-.src, -.pos, -x, -y) %>% lclgetfltout_df() %>% mutate(obj.distance = (((as.numeric(x) - left_eye_center_x.int) ^ 2) + ((as.numeric(y) - left_eye_center_y.int) ^ 2)) ^ 0.5) %>% dplyr::top_n(5, obj.distance) %>% dplyr::top_n(5, -patch.cor)
#
#newImgObs <- glbObsNew[(glbObsNew$ImageId == "Test#0001"), ]; print(newImgObs[which.max(newImgObs$label.fctr.Final..rcv.glmnet.prob), ])
#OOBImgObs <- glbObsOOB[(glbObsOOB$ImageId == "Train#0003"), ]; print(OOBImgObs[which.max(OOBImgObs$label.fctr.All.X..rcv.glmnet.prob), ])

#mygetImage(which(glbObsAll[, glbFeatsId] == "Train#0003"), names(glbFeatsImage)[1], plot = TRUE, featHighlight = c("left_eye_center_x", "left_eye_center_y"), ovrlHighlight = c(66, 35))

# Depict process
glb_analytics_pn <- petrinet(name = "glb_analytics_pn",
                        trans_df = data.frame(id = 1:6,
    name = c("data.training.all","data.new",
           "model.selected","model.final",
           "data.training.all.prediction","data.new.prediction"),
    x=c(   -5,-5,-15,-25,-25,-35),
    y=c(   -5, 5,  0,  0, -5,  5)
                        ),
                        places_df=data.frame(id=1:4,
    name=c("bgn","fit.data.training.all","predict.data.new","end"),
    x=c(   -0,   -20,                    -30,               -40),
    y=c(    0,     0,                      0,                 0),
    M0=c(   3,     0,                      0,                 0)
                        ),
                        arcs_df = data.frame(
    begin = c("bgn","bgn","bgn",        
            "data.training.all","model.selected","fit.data.training.all",
            "fit.data.training.all","model.final",    
            "data.new","predict.data.new",
            "data.training.all.prediction","data.new.prediction"),
    end   = c("data.training.all","data.new","model.selected",
            "fit.data.training.all","fit.data.training.all","model.final",
            "data.training.all.prediction","predict.data.new",
            "predict.data.new","data.new.prediction",
            "end","end")
                        ))
#print(ggplot.petrinet(glb_analytics_pn))
print(ggplot.petrinet(glb_analytics_pn) + coord_flip())
## Loading required package: grid

glb_analytics_avl_objs <- NULL

glb_chunks_df <- myadd_chunk(NULL, 
                             ifelse(is.null(glbChunks$first), "import.data", glbChunks$first))
##         label step_major step_minor label_minor  bgn end elapsed
## 1 import.data          1          0           0 5.75  NA      NA

Step 1.0: import data

chunk option: eval=

## [1] "Reading file ./data/train2016.csv..."
## [1] "dimensions of data in ./data/train2016.csv: 5,568 rows x 108 cols"
##   USER_ID  YOB Gender              Income            HouseholdStatus
## 1       1 1938   Male                               Married (w/kids)
## 2       4 1970 Female       over $150,000 Domestic Partners (w/kids)
## 3       5 1997   Male  $75,000 - $100,000           Single (no kids)
## 4       8 1983   Male $100,001 - $150,000           Married (w/kids)
## 5       9 1984 Female   $50,000 - $74,999           Married (w/kids)
## 6      10 1997 Female       over $150,000           Single (no kids)
##        EducationLevel      Party Q124742 Q124122 Q123464 Q123621 Q122769
## 1                       Democrat      No              No      No      No
## 2   Bachelor's Degree   Democrat             Yes      No      No      No
## 3 High School Diploma Republican             Yes     Yes      No        
## 4   Bachelor's Degree   Democrat      No     Yes      No     Yes      No
## 5 High School Diploma Republican      No     Yes      No      No      No
## 6        Current K-12   Democrat                                      No
##   Q122770 Q122771 Q122120 Q121699 Q121700 Q120978 Q121011 Q120379 Q120650
## 1     Yes  Public      No     Yes      No              No      No     Yes
## 2     Yes  Public      No     Yes      No     Yes      No      No     Yes
## 3     Yes Private      No      No      No     Yes      No      No     Yes
## 4      No  Public      No     Yes      No     Yes      No      No     Yes
## 5     Yes  Public      No     Yes      No     Yes     Yes      No     Yes
## 6     Yes  Public      No      No      No     Yes      No     Yes     Yes
##   Q120472     Q120194 Q120012 Q120014 Q119334 Q119851   Q119650 Q118892
## 1           Try first      No      No             Yes               Yes
## 2 Science Study first     Yes     Yes      No      No Receiving      No
## 3 Science Study first             Yes      No     Yes Receiving      No
## 4 Science   Try first      No     Yes     Yes      No    Giving     Yes
## 5     Art   Try first     Yes      No      No      No    Giving      No
## 6 Science   Try first     Yes     Yes      No     Yes Receiving      No
##   Q118117    Q118232 Q118233 Q118237     Q117186        Q117193 Q116797
## 1     Yes   Idealist      No      No                                Yes
## 2      No Pragmatist      No      No Cool headed Standard hours      No
## 3     Yes Pragmatist      No     Yes Cool headed      Odd hours      No
## 4      No   Idealist      No      No Cool headed Standard hours      No
## 5      No   Idealist     Yes     Yes  Hot headed Standard hours      No
## 6      No Pragmatist      No      No             Standard hours        
##   Q116881 Q116953 Q116601 Q116441 Q116448 Q116197 Q115602 Q115777 Q115610
## 1   Happy     Yes     Yes      No      No    P.M.     Yes   Start     Yes
## 2   Happy     Yes     Yes     Yes      No    A.M.      No     End     Yes
## 3   Right     Yes      No      No     Yes    A.M.     Yes   Start     Yes
## 4   Happy     Yes     Yes      No      No    A.M.     Yes   Start     Yes
## 5   Happy     Yes     Yes      No     Yes    P.M.      No     End      No
## 6                                                                        
##   Q115611       Q115899 Q115390 Q114961 Q114748 Q115195 Q114517    Q114386
## 1      No Circumstances     Yes     Yes     Yes     Yes      No           
## 2      No            Me     Yes     Yes      No     Yes      No Mysterious
## 3     Yes Circumstances      No     Yes      No     Yes     Yes Mysterious
## 4      No Circumstances     Yes      No      No     Yes      No        TMI
## 5      No            Me      No     Yes     Yes     Yes     Yes        TMI
## 6                                                                         
##   Q113992 Q114152 Q113583    Q113584 Q113181 Q112478 Q112512 Q112270
## 1     Yes     Yes    Talk Technology      No      No     Yes        
## 2      No      No                                                   
## 3      No      No   Tunes Technology     Yes     Yes     Yes     Yes
## 4      No      No    Talk     People      No     Yes     Yes     Yes
## 5     Yes      No   Tunes     People      No      No     Yes      No
## 6                                                                   
##   Q111848    Q111580 Q111220 Q110740 Q109367       Q108950 Q109244 Q108855
## 1      No  Demanding      No              No      Cautious      No    Yes!
## 2                                Mac     Yes      Cautious      No  Umm...
## 3      No Supportive      No      PC      No      Cautious      No  Umm...
## 4     Yes Supportive      No     Mac     Yes Risk-friendly      No  Umm...
## 5      No  Demanding     Yes      PC     Yes      Cautious      No    Yes!
## 6     Yes Supportive      No      PC                                      
##   Q108617   Q108856 Q108754   Q108342 Q108343 Q107869 Q107491 Q106993
## 1      No     Space      No In-person             Yes      No     Yes
## 2      No     Space     Yes In-person      No     Yes     Yes      No
## 3      No     Space      No In-person      No      No     Yes     Yes
## 4      No Socialize     Yes    Online      No     Yes      No     Yes
## 5      No Socialize      No    Online      No      No     Yes     Yes
## 6                           In-person      No      No     Yes     Yes
##       Q106997 Q106272 Q106388 Q106389 Q106042 Q105840 Q105655 Q104996
## 1 Yay people!     Yes      No     Yes     Yes              No     Yes
## 2 Yay people!     Yes     Yes     Yes     Yes     Yes      No     Yes
## 3 Grrr people     Yes      No      No      No      No      No      No
## 4 Grrr people      No      No     Yes     Yes      No     Yes     Yes
## 5 Yay people!     Yes      No     Yes     Yes     Yes     Yes      No
## 6 Grrr people     Yes      No     Yes     Yes      No      No     Yes
##   Q103293 Q102906 Q102674 Q102687 Q102289 Q102089   Q101162 Q101163
## 1      No      No      No     Yes      No     Own  Optimist        
## 2                                                                  
## 3     Yes      No      No     Yes      No     Own Pessimist     Mom
## 4      No      No      No     Yes     Yes     Own  Optimist     Mom
## 5      No      No     Yes      No      No     Own  Optimist     Mom
## 6     Yes     Yes      No     Yes                                  
##   Q101596 Q100689 Q100680 Q100562 Q99982 Q100010 Q99716 Q99581 Q99480
## 1     Yes     Yes      No      No   Nope     Yes     No     No       
## 2                                                                  No
## 3      No      No      No      No   Nope     Yes     No     No     No
## 4      No      No      No     Yes Check!      No     No     No    Yes
## 5      No     Yes     Yes     Yes   Nope     Yes     No     No    Yes
## 6                                                                    
##   Q98869 Q98578     Q98059 Q98078 Q98197 Q96024
## 1     No        Only-child     No     No    Yes
## 2     No     No Only-child    Yes     No     No
## 3    Yes     No        Yes     No    Yes     No
## 4    Yes     No        Yes     No     No    Yes
## 5     No     No        Yes     No     No    Yes
## 6                                              
##      USER_ID  YOB Gender              Income             HouseholdStatus
## 193      245 1964   Male       over $150,000            Married (w/kids)
## 848     1046 1953   Male $100,001 - $150,000 Domestic Partners (no kids)
## 2836    3530 1995   Male                                Single (no kids)
## 4052    5050 1945 Female  $75,000 - $100,000            Married (w/kids)
## 4093    5107 1980 Female $100,001 - $150,000            Married (w/kids)
## 5509    6888 1998 Female       under $25,000            Single (no kids)
##             EducationLevel      Party Q124742 Q124122 Q123464 Q123621
## 193      Bachelor's Degree Republican     Yes     Yes      No     Yes
## 848                          Democrat                                
## 2836 Current Undergraduate   Democrat     Yes     Yes     Yes      No
## 4052     Bachelor's Degree Republican                                
## 4093     Bachelor's Degree   Democrat                      No      No
## 5509          Current K-12 Republican                                
##      Q122769 Q122770 Q122771 Q122120 Q121699 Q121700 Q120978 Q121011
## 193       No     Yes  Public      No     Yes      No     Yes      No
## 848                                                                 
## 2836             Yes  Public     Yes      No      No     Yes     Yes
## 4052              No  Public                                        
## 4093      No      No Private      No                                
## 5509                                                     Yes     Yes
##      Q120379 Q120650 Q120472     Q120194 Q120012 Q120014 Q119334 Q119851
## 193       No     Yes Science   Try first     Yes     Yes     Yes      No
## 848                                                                     
## 2836     Yes     Yes     Art Study first      No     Yes             Yes
## 4052                                                                    
## 4093                                                         Yes        
## 5509     Yes      No     Art Study first     Yes      No     Yes      No
##      Q119650 Q118892 Q118117    Q118232 Q118233 Q118237     Q117186
## 193   Giving     Yes      No   Idealist     Yes     Yes  Hot headed
## 848                                                                
## 2836             Yes     Yes   Idealist     Yes      No Cool headed
## 4052                      No                 No      No            
## 4093              No      No Pragmatist      No     Yes            
## 5509  Giving      No                                               
##             Q117193 Q116797 Q116881 Q116953 Q116601 Q116441 Q116448
## 193  Standard hours      No   Happy     Yes     Yes      No      No
## 848                                                                
## 2836      Odd hours      No   Happy     Yes     Yes              No
## 4052                                                               
## 4093                                                               
## 5509                                                               
##      Q116197 Q115602 Q115777 Q115610 Q115611       Q115899 Q115390 Q114961
## 193     A.M.     Yes     End     Yes     Yes            Me      No      No
## 848                                                                       
## 2836             Yes     End     Yes      No Circumstances     Yes      No
## 4052    P.M.     Yes   Start     Yes      No                    No        
## 4093    P.M.     Yes   Start     Yes      No Circumstances                
## 5509                                                                      
##      Q114748 Q115195 Q114517    Q114386 Q113992 Q114152 Q113583    Q113584
## 193      Yes      No     Yes        TMI      No     Yes   Tunes Technology
## 848                                                                       
## 2836     Yes      No      No Mysterious      No     Yes   Tunes     People
## 4052      No     Yes                                                      
## 4093                                                      Tunes     People
## 5509                                                                      
##      Q113181 Q112478 Q112512 Q112270 Q111848    Q111580 Q111220 Q110740
## 193       No     Yes             Yes     Yes Supportive      No     Mac
## 848                                                                    
## 2836     Yes     Yes     Yes      No     Yes  Demanding     Yes      PC
## 4052                                                                   
## 4093                                     Yes Supportive                
## 5509                                                                   
##      Q109367       Q108950 Q109244 Q108855 Q108617   Q108856 Q108754
## 193       No      Cautious      No    Yes!      No Socialize      No
## 848      Yes Risk-friendly     Yes    Yes!      No     Space      No
## 2836     Yes      Cautious     Yes             Yes                  
## 4052                                                                
## 4093      No Risk-friendly      No    Yes!      No     Space      No
## 5509                                                                
##        Q108342 Q108343 Q107869 Q107491 Q106993     Q106997 Q106272 Q106388
## 193  In-person      No     Yes     Yes      No Yay people!     Yes     Yes
## 848  In-person     Yes                                                    
## 2836 In-person     Yes             Yes                         Yes      No
## 4052                                        No Grrr people                
## 4093 In-person     Yes     Yes     Yes     Yes Yay people!     Yes     Yes
## 5509                                                                      
##      Q106389 Q106042 Q105840 Q105655 Q104996 Q103293 Q102906 Q102674
## 193       No     Yes      No      No     Yes      No      No      No
## 848                                                                 
## 2836     Yes      No      No      No     Yes     Yes      No      No
## 4052                              No      No      No              No
## 4093      No      No      No      No     Yes      No      No     Yes
## 5509                                                                
##      Q102687 Q102289 Q102089  Q101162 Q101163 Q101596 Q100689 Q100680
## 193       No      No     Own Optimist     Dad     Yes     Yes      No
## 848                                                                  
## 2836     Yes     Yes    Rent Optimist     Dad      No     Yes     Yes
## 4052     Yes             Own                       No                
## 4093     Yes     Yes    Rent                               No     Yes
## 5509                                                                 
##      Q100562 Q99982 Q100010 Q99716 Q99581 Q99480 Q98869 Q98578 Q98059
## 193      Yes Check!      No     No     No    Yes    Yes     No    Yes
## 848                                                                  
## 2836     Yes Check!      No     No     No    Yes    Yes           Yes
## 4052                                                                 
## 4093      No   Nope     Yes     No    Yes    Yes    Yes     No    Yes
## 5509                                                                 
##      Q98078 Q98197 Q96024
## 193      No    Yes    Yes
## 848                    No
## 2836    Yes    Yes     No
## 4052                     
## 4093    Yes    Yes     No
## 5509                     
##      USER_ID  YOB Gender            Income  HouseholdStatus
## 5563    6955 1966   Male     over $150,000 Married (w/kids)
## 5564    6956   NA   Male                                   
## 5565    6957 2000 Female                                   
## 5566    6958 1969   Male     over $150,000                 
## 5567    6959 1986   Male $25,001 - $50,000 Married (w/kids)
## 5568    6960 1999   Male     under $25,000 Single (no kids)
##           EducationLevel      Party Q124742 Q124122 Q123464 Q123621
## 5563   Bachelor's Degree   Democrat                                
## 5564     Master's Degree   Democrat              No      No        
## 5565        Current K-12 Republican                                
## 5566   Bachelor's Degree   Democrat                             Yes
## 5567 High School Diploma Republican                                
## 5568        Current K-12 Republican                                
##      Q122769 Q122770 Q122771 Q122120 Q121699 Q121700 Q120978 Q121011
## 5563                              No     Yes      No     Yes     Yes
## 5564      No     Yes  Public             Yes                        
## 5565                  Public                             Yes        
## 5566                              No      No      No     Yes     Yes
## 5567                             Yes             Yes              No
## 5568                                     Yes      No      No        
##      Q120379 Q120650 Q120472   Q120194 Q120012 Q120014 Q119334 Q119851
## 5563                                                                  
## 5564                                                                  
## 5565     Yes     Yes     Art Try first      No     Yes     Yes     Yes
## 5566     Yes     Yes Science                                          
## 5567      No      No Science                No     Yes                
## 5568                                                                  
##        Q119650 Q118892 Q118117 Q118232 Q118233 Q118237 Q117186 Q117193
## 5563                                                                  
## 5564                                                                  
## 5565 Receiving                                                        
## 5566                                                                  
## 5567                                                                  
## 5568                                                                  
##      Q116797 Q116881 Q116953 Q116601 Q116441 Q116448 Q116197 Q115602
## 5563                                                                
## 5564                                                                
## 5565                                                                
## 5566                                                                
## 5567                                                                
## 5568                                                                
##      Q115777 Q115610 Q115611 Q115899 Q115390 Q114961 Q114748 Q115195
## 5563                                                                
## 5564                                                                
## 5565                                                                
## 5566                                                                
## 5567                                                                
## 5568                                                                
##      Q114517 Q114386 Q113992 Q114152 Q113583 Q113584 Q113181 Q112478
## 5563                                                                
## 5564                                                                
## 5565                                                                
## 5566                                                                
## 5567                                                                
## 5568                                                                
##      Q112512 Q112270 Q111848 Q111580 Q111220 Q110740 Q109367 Q108950
## 5563                                                                
## 5564                                                                
## 5565                                                                
## 5566                                                                
## 5567                                                                
## 5568                                                                
##      Q109244 Q108855 Q108617 Q108856 Q108754 Q108342 Q108343 Q107869
## 5563                                                                
## 5564                                                                
## 5565                                                                
## 5566                                                                
## 5567                                                                
## 5568                                                                
##      Q107491 Q106993 Q106997 Q106272 Q106388 Q106389 Q106042 Q105840
## 5563                                                                
## 5564                                                                
## 5565                                                                
## 5566                                                                
## 5567                                                                
## 5568                                                                
##      Q105655 Q104996 Q103293 Q102906 Q102674 Q102687 Q102289 Q102089
## 5563                                                                
## 5564                                                                
## 5565                                                                
## 5566                                                                
## 5567                                                                
## 5568                                                                
##      Q101162 Q101163 Q101596 Q100689 Q100680 Q100562 Q99982 Q100010 Q99716
## 5563                                                                      
## 5564                                                                      
## 5565                                                                      
## 5566                                                                      
## 5567                                                                      
## 5568                                                                      
##      Q99581 Q99480 Q98869 Q98578 Q98059 Q98078 Q98197 Q96024
## 5563                                                        
## 5564                                                        
## 5565                                                        
## 5566                                                        
## 5567                                                        
## 5568                                                        
## 'data.frame':    5568 obs. of  20 variables:
##  $ USER_ID        : int  1 4 5 8 9 10 11 12 13 15 ...
##  $ YOB            : int  1938 1970 1997 1983 1984 1997 1983 1996 NA 1981 ...
##  $ Gender         : chr  "Male" "Female" "Male" "Male" ...
##  $ Income         : chr  "" "over $150,000" "$75,000 - $100,000" "$100,001 - $150,000" ...
##  $ HouseholdStatus: chr  "Married (w/kids)" "Domestic Partners (w/kids)" "Single (no kids)" "Married (w/kids)" ...
##  $ EducationLevel : chr  "" "Bachelor's Degree" "High School Diploma" "Bachelor's Degree" ...
##  $ Party          : chr  "Democrat" "Democrat" "Republican" "Democrat" ...
##  $ Q124742        : chr  "No" "" "" "No" ...
##  $ Q124122        : chr  "" "Yes" "Yes" "Yes" ...
##  $ Q123464        : chr  "No" "No" "Yes" "No" ...
##  $ Q123621        : chr  "No" "No" "No" "Yes" ...
##  $ Q122769        : chr  "No" "No" "" "No" ...
##  $ Q122770        : chr  "Yes" "Yes" "Yes" "No" ...
##  $ Q122771        : chr  "Public" "Public" "Private" "Public" ...
##  $ Q122120        : chr  "No" "No" "No" "No" ...
##  $ Q121699        : chr  "Yes" "Yes" "No" "Yes" ...
##  $ Q121700        : chr  "No" "No" "No" "No" ...
##  $ Q120978        : chr  "" "Yes" "Yes" "Yes" ...
##  $ Q121011        : chr  "No" "No" "No" "No" ...
##  $ Q120379        : chr  "No" "No" "No" "No" ...
## NULL
## 'data.frame':    5568 obs. of  20 variables:
##  $ Q120650: chr  "Yes" "Yes" "Yes" "Yes" ...
##  $ Q118117: chr  "Yes" "No" "Yes" "No" ...
##  $ Q118233: chr  "No" "No" "No" "No" ...
##  $ Q118237: chr  "No" "No" "Yes" "No" ...
##  $ Q116441: chr  "No" "Yes" "No" "No" ...
##  $ Q116197: chr  "P.M." "A.M." "A.M." "A.M." ...
##  $ Q115611: chr  "No" "No" "Yes" "No" ...
##  $ Q115899: chr  "Circumstances" "Me" "Circumstances" "Circumstances" ...
##  $ Q115390: chr  "Yes" "Yes" "No" "Yes" ...
##  $ Q114748: chr  "Yes" "No" "No" "No" ...
##  $ Q115195: chr  "Yes" "Yes" "Yes" "Yes" ...
##  $ Q113584: chr  "Technology" "" "Technology" "People" ...
##  $ Q112478: chr  "No" "" "Yes" "Yes" ...
##  $ Q112270: chr  "" "" "Yes" "Yes" ...
##  $ Q111848: chr  "No" "" "No" "Yes" ...
##  $ Q106993: chr  "Yes" "No" "Yes" "Yes" ...
##  $ Q106388: chr  "No" "Yes" "No" "No" ...
##  $ Q105655: chr  "No" "No" "No" "Yes" ...
##  $ Q104996: chr  "Yes" "Yes" "No" "Yes" ...
##  $ Q102674: chr  "No" "" "No" "No" ...
## NULL
## 'data.frame':    5568 obs. of  21 variables:
##  $ Q102674: chr  "No" "" "No" "No" ...
##  $ Q102687: chr  "Yes" "" "Yes" "Yes" ...
##  $ Q102289: chr  "No" "" "No" "Yes" ...
##  $ Q102089: chr  "Own" "" "Own" "Own" ...
##  $ Q101162: chr  "Optimist" "" "Pessimist" "Optimist" ...
##  $ Q101163: chr  "" "" "Mom" "Mom" ...
##  $ Q101596: chr  "Yes" "" "No" "No" ...
##  $ Q100689: chr  "Yes" "" "No" "No" ...
##  $ Q100680: chr  "No" "" "No" "No" ...
##  $ Q100562: chr  "No" "" "No" "Yes" ...
##  $ Q99982 : chr  "Nope" "" "Nope" "Check!" ...
##  $ Q100010: chr  "Yes" "" "Yes" "No" ...
##  $ Q99716 : chr  "No" "" "No" "No" ...
##  $ Q99581 : chr  "No" "" "No" "No" ...
##  $ Q99480 : chr  "" "No" "No" "Yes" ...
##  $ Q98869 : chr  "No" "No" "Yes" "Yes" ...
##  $ Q98578 : chr  "" "No" "No" "No" ...
##  $ Q98059 : chr  "Only-child" "Only-child" "Yes" "Yes" ...
##  $ Q98078 : chr  "No" "Yes" "No" "No" ...
##  $ Q98197 : chr  "No" "No" "Yes" "No" ...
##  $ Q96024 : chr  "Yes" "No" "No" "Yes" ...
## NULL
## Warning in myprint_str_df(obsDf): [list output truncated]
## [1] "Reading file ./data/test2016.csv..."
## [1] "dimensions of data in ./data/test2016.csv: 1,392 rows x 107 cols"
##   USER_ID  YOB Gender             Income   HouseholdStatus
## 1       2 1985 Female  $25,001 - $50,000  Single (no kids)
## 2       3 1983   Male  $50,000 - $74,999  Married (w/kids)
## 3       6 1995   Male $75,000 - $100,000  Single (no kids)
## 4       7 1980 Female  $50,000 - $74,999  Single (no kids)
## 5      14 1980 Female                    Married (no kids)
## 6      28 1973   Male      over $150,000 Married (no kids)
##          EducationLevel Q124742 Q124122 Q123464 Q123621 Q122769 Q122770
## 1       Master's Degree             Yes      No     Yes      No      No
## 2 Current Undergraduate                      No             Yes     Yes
## 3          Current K-12                                                
## 4       Master's Degree     Yes     Yes      No     Yes     Yes     Yes
## 5 Current Undergraduate             Yes      No     Yes      No      No
## 6       Master's Degree      No     Yes      No     Yes      No      No
##   Q122771 Q122120 Q121699 Q121700 Q120978 Q121011 Q120379 Q120650 Q120472
## 1  Public      No     Yes     Yes     Yes      No     Yes     Yes Science
## 2  Public      No     Yes      No                                        
## 3                      No      No      No     Yes      No     Yes Science
## 4  Public      No     Yes      No     Yes      No     Yes     Yes Science
## 5  Public     Yes     Yes      No     Yes     Yes      No     Yes     Art
## 6  Public      No     Yes      No     Yes     Yes     Yes     Yes Science
##       Q120194 Q120012 Q120014 Q119334 Q119851 Q119650 Q118892 Q118117
## 1 Study first     Yes     Yes     Yes      No  Giving     Yes      No
## 2 Study first      No     Yes              No                        
## 3   Try first      No     Yes      No     Yes  Giving                
## 4   Try first     Yes      No      No     Yes  Giving     Yes     Yes
## 5   Try first     Yes     Yes     Yes     Yes  Giving      No      No
## 6   Try first     Yes     Yes      No      No  Giving      No     Yes
##      Q118232 Q118233 Q118237     Q117186        Q117193 Q116797 Q116881
## 1   Idealist      No     Yes Cool headed      Odd hours     Yes   Happy
## 2                                                                      
## 3                                                                      
## 4   Idealist      No      No Cool headed Standard hours      No   Happy
## 5   Idealist      No     Yes  Hot headed Standard hours     Yes   Happy
## 6 Pragmatist     Yes      No  Hot headed      Odd hours     Yes   Right
##   Q116953 Q116601 Q116441 Q116448 Q116197 Q115602 Q115777 Q115610 Q115611
## 1     Yes     Yes      No     Yes    A.M.     Yes     End     Yes      No
## 2     Yes     Yes                    P.M.                                
## 3     Yes                                                                
## 4     Yes      No      No     Yes    A.M.     Yes   Start     Yes      No
## 5     Yes     Yes     Yes      No    P.M.     Yes     End      No      No
## 6     Yes     Yes     Yes     Yes    P.M.             End     Yes     Yes
##         Q115899 Q115390 Q114961 Q114748 Q115195 Q114517 Q114386 Q113992
## 1            Me      No     Yes      No     Yes     Yes     TMI        
## 2                                            No                     Yes
## 3                   Yes      No     Yes     Yes      No     TMI      No
## 4            Me     Yes      No     Yes     Yes     Yes     TMI      No
## 5            Me      No      No      No     Yes      No     TMI      No
## 6 Circumstances      No     Yes      No     Yes      No     TMI     Yes
##   Q114152 Q113583    Q113584 Q113181 Q112478 Q112512 Q112270 Q111848
## 1      No   Tunes     People     Yes     Yes      No     Yes     Yes
## 2      No                         No                      No     Yes
## 3      No   Tunes Technology     Yes      No     Yes      No        
## 4     Yes    Talk     People      No      No     Yes      No     Yes
## 5           Tunes Technology      No     Yes     Yes             Yes
## 6      No    Talk Technology      No     Yes     Yes      No     Yes
##      Q111580 Q111220 Q110740 Q109367  Q108950 Q109244 Q108855 Q108617
## 1 Supportive      No             Yes Cautious     Yes    Yes!        
## 2                 No             Yes Cautious      No    Yes!      No
## 3                                 No               No              No
## 4 Supportive      No      PC      No Cautious     Yes    Yes!      No
## 5 Supportive     Yes     Mac     Yes Cautious      No    Yes!      No
## 6  Demanding      No      PC     Yes Cautious      No  Umm...      No
##   Q108856 Q108754   Q108342 Q108343 Q107869 Q107491 Q106993     Q106997
## 1             Yes In-person     Yes                                    
## 2   Space      No                       Yes     Yes     Yes Grrr people
## 3             Yes In-person      No      No     Yes     Yes Yay people!
## 4   Space      No    Online      No      No     Yes     Yes Yay people!
## 5   Space      No In-person      No      No     Yes      No Grrr people
## 6   Space      No In-person     Yes             Yes     Yes Grrr people
##   Q106272 Q106388 Q106389 Q106042 Q105840 Q105655 Q104996 Q103293 Q102906
## 1                                                                        
## 2     Yes      No      No     Yes      No     Yes      No      No        
## 3     Yes      No     Yes      No      No     Yes     Yes      No      No
## 4      No      No      No      No      No     Yes     Yes      No      No
## 5      No      No      No     Yes     Yes     Yes     Yes     Yes      No
## 6     Yes      No     Yes     Yes      No      No      No     Yes     Yes
##   Q102674 Q102687 Q102289 Q102089   Q101162 Q101163 Q101596 Q100689
## 1                                                                No
## 2                            Rent Pessimist     Dad                
## 3      No      No     Yes     Own  Optimist     Mom      No      No
## 4      No      No      No     Own  Optimist     Dad      No      No
## 5     Yes      No      No     Own Pessimist     Mom      No     Yes
## 6     Yes     Yes      No     Own Pessimist     Mom      No     Yes
##   Q100680 Q100562 Q99982 Q100010 Q99716 Q99581 Q99480 Q98869 Q98578 Q98059
## 1     Yes     Yes                                        Yes              
## 2             Yes                                        Yes           Yes
## 3     Yes     Yes   Nope      No     No     No    Yes    Yes     No    Yes
## 4     Yes     Yes   Nope     Yes     No     No     No    Yes     No    Yes
## 5     Yes     Yes   Nope     Yes     No     No    Yes     No     No    Yes
## 6     Yes     Yes   Nope     Yes     No     No    Yes     No     No    Yes
##   Q98078 Q98197 Q96024
## 1                     
## 2    Yes     No    Yes
## 3     No    Yes    Yes
## 4     No     No    Yes
## 5     No     No     No
## 6     No     No    Yes
##      USER_ID  YOB Gender              Income   HouseholdStatus
## 503     2555 1956   Male       over $150,000  Married (w/kids)
## 515     2616 1959   Male       over $150,000  Married (w/kids)
## 857     4346 1990 Female   $50,000 - $74,999                  
## 950     4814 1969   Male  $75,000 - $100,000  Married (w/kids)
## 1207    6057 1937 Female   $25,001 - $50,000 Married (no kids)
## 1255    6285 1976 Female $100,001 - $150,000 Married (no kids)
##         EducationLevel Q124742 Q124122 Q123464 Q123621 Q122769 Q122770
## 503  Bachelor's Degree      No      No      No     Yes      No     Yes
## 515  Bachelor's Degree                                                
## 857  Bachelor's Degree                                                
## 950  Bachelor's Degree             Yes      No     Yes      No      No
## 1207 Bachelor's Degree                                      No     Yes
## 1255 Bachelor's Degree                                                
##      Q122771 Q122120 Q121699 Q121700 Q120978 Q121011 Q120379 Q120650
## 503  Private      No     Yes      No      No     Yes      No     Yes
## 515               No      No                                        
## 857               No     Yes      No      No      No      No     Yes
## 950   Public     Yes     Yes      No     Yes     Yes      No     Yes
## 1207  Public      No     Yes      No      No      No              No
## 1255                                                                
##      Q120472     Q120194 Q120012 Q120014 Q119334 Q119851   Q119650 Q118892
## 503  Science Study first      No     Yes      No     Yes    Giving     Yes
## 515                                                                    Yes
## 857  Science Study first      No      No     Yes      No Receiving     Yes
## 950  Science Study first      No      No      No      No    Giving      No
## 1207         Study first      No      No             Yes Receiving     Yes
## 1255                                                                      
##      Q118117    Q118232 Q118233 Q118237     Q117186        Q117193 Q116797
## 503       No Pragmatist      No      No Cool headed Standard hours      No
## 515       No Pragmatist      No     Yes Cool headed Standard hours      No
## 857      Yes Pragmatist      No      No Cool headed      Odd hours      No
## 950       No Pragmatist      No     Yes  Hot headed      Odd hours     Yes
## 1207      No Pragmatist      No      No  Hot headed                     No
## 1255                                                                      
##      Q116881 Q116953 Q116601 Q116441 Q116448 Q116197 Q115602 Q115777
## 503    Happy     Yes     Yes      No      No    A.M.     Yes     End
## 515    Right     Yes     Yes      No     Yes             Yes        
## 857    Right     Yes     Yes      No      No    A.M.     Yes   Start
## 950    Happy     Yes     Yes     Yes      No    P.M.     Yes   Start
## 1207   Happy     Yes     Yes      No      No    A.M.     Yes   Start
## 1255                     Yes      No     Yes    A.M.     Yes   Start
##      Q115610 Q115611       Q115899 Q115390 Q114961 Q114748 Q115195 Q114517
## 503      Yes     Yes            Me      No      No      No     Yes     Yes
## 515      Yes      No            Me     Yes      No     Yes     Yes      No
## 857      Yes      No            Me              No      No      No     Yes
## 950      Yes      No            Me     Yes      No     Yes      No      No
## 1207      No      No Circumstances     Yes      No     Yes      No     Yes
## 1255     Yes      No Circumstances      No     Yes      No     Yes     Yes
##         Q114386 Q113992 Q114152 Q113583    Q113584 Q113181 Q112478 Q112512
## 503         TMI     Yes     Yes   Tunes     People     Yes      No     Yes
## 515                  No     Yes    Talk Technology                        
## 857  Mysterious      No      No   Tunes     People      No      No      No
## 950  Mysterious      No      No   Tunes     People     Yes     Yes     Yes
## 1207                Yes      No    Talk                                Yes
## 1255        TMI             Yes                                Yes     Yes
##      Q112270 Q111848    Q111580 Q111220 Q110740 Q109367       Q108950
## 503       No     Yes  Demanding      No      PC      No      Cautious
## 515       No     Yes                 No     Mac     Yes              
## 857      Yes     Yes Supportive      No     Mac      No Risk-friendly
## 950       No     Yes Supportive     Yes      PC      No      Cautious
## 1207                 Supportive      No      PC              Cautious
## 1255     Yes     Yes  Demanding      No     Mac                      
##      Q109244 Q108855 Q108617 Q108856 Q108754   Q108342 Q108343 Q107869
## 503       No  Umm...      No   Space      No In-person      No     Yes
## 515                                                                   
## 857      Yes  Umm...      No   Space      No In-person      No     Yes
## 950       No    Yes!      No   Space      No In-person      No      No
## 1207            Yes!      No   Space      No In-person      No     Yes
## 1255                                                                  
##      Q107491 Q106993     Q106997 Q106272 Q106388 Q106389 Q106042 Q105840
## 503      Yes     Yes Yay people!     Yes      No      No     Yes      No
## 515                                                                   No
## 857       No     Yes Grrr people     Yes      No     Yes      No      No
## 950      Yes      No Grrr people     Yes     Yes      No      No      No
## 1207     Yes     Yes                 Yes                                
## 1255                                                                    
##      Q105655 Q104996 Q103293 Q102906 Q102674 Q102687 Q102289 Q102089
## 503       No     Yes      No      No      No     Yes      No     Own
## 515      Yes     Yes                                                
## 857       No     Yes     Yes      No      No     Yes     Yes     Own
## 950      Yes     Yes     Yes      No      No     Yes      No     Own
## 1207     Yes                                                        
## 1255                                                                
##        Q101162 Q101163 Q101596 Q100689 Q100680 Q100562 Q99982 Q100010
## 503  Pessimist     Mom     Yes     Yes      No     Yes Check!     Yes
## 515                                                    Check!     Yes
## 857   Optimist     Mom      No     Yes     Yes      No   Nope     Yes
## 950  Pessimist     Mom     Yes      No      No      No Check!     Yes
## 1207                                                                 
## 1255                                                                 
##      Q99716 Q99581 Q99480 Q98869 Q98578 Q98059 Q98078 Q98197 Q96024
## 503      No     No    Yes    Yes     No    Yes    Yes    Yes    Yes
## 515             No    Yes    Yes           Yes     No    Yes    Yes
## 857      No    Yes    Yes    Yes     No    Yes     No     No     No
## 950      No     No    Yes    Yes     No    Yes     No    Yes    Yes
## 1207                                                               
## 1255                                                               
##      USER_ID  YOB Gender              Income             HouseholdStatus
## 1387    6922 1988   Male   $50,000 - $74,999            Single (no kids)
## 1388    6928 1977 Female   $50,000 - $74,999 Domestic Partners (no kids)
## 1389    6930 1998 Female $100,001 - $150,000            Single (no kids)
## 1390    6941 1989   Male   $25,001 - $50,000           Married (no kids)
## 1391    6946 1996   Male                                                
## 1392    6947   NA Female                                                
##         EducationLevel Q124742 Q124122 Q123464 Q123621 Q122769 Q122770
## 1387   Master's Degree                                                
## 1388   Master's Degree                                                
## 1389      Current K-12                                      No      No
## 1390 Bachelor's Degree                                                
## 1391      Current K-12                                                
## 1392                       Yes     Yes      No      No      No      No
##      Q122771 Q122120 Q121699 Q121700 Q120978 Q121011 Q120379 Q120650
## 1387                     Yes     Yes     Yes     Yes     Yes     Yes
## 1388                             Yes              No             Yes
## 1389  Public     Yes     Yes     Yes     Yes     Yes     Yes     Yes
## 1390             Yes     Yes      No      No      No                
## 1391             Yes      No      No     Yes      No     Yes     Yes
## 1392  Public     Yes     Yes      No     Yes     Yes     Yes     Yes
##      Q120472     Q120194 Q120012 Q120014 Q119334 Q119851 Q119650 Q118892
## 1387 Science   Try first      No     Yes     Yes      No  Giving        
## 1388     Art                                                            
## 1389     Art Study first     Yes      No     Yes      No  Giving        
## 1390                                                                    
## 1391     Art Study first     Yes     Yes     Yes      No  Giving        
## 1392     Art                  No      No      No     Yes  Giving        
##      Q118117 Q118232 Q118233 Q118237 Q117186 Q117193 Q116797 Q116881
## 1387                                                                
## 1388                                                                
## 1389                                                                
## 1390                                                                
## 1391                                                                
## 1392                                                                
##      Q116953 Q116601 Q116441 Q116448 Q116197 Q115602 Q115777 Q115610
## 1387                                                                
## 1388                                                                
## 1389                                                                
## 1390                                                                
## 1391                                                                
## 1392                                                                
##      Q115611 Q115899 Q115390 Q114961 Q114748 Q115195 Q114517 Q114386
## 1387                                                                
## 1388                                                                
## 1389                                                                
## 1390                                                                
## 1391                                                                
## 1392                                                                
##      Q113992 Q114152 Q113583 Q113584 Q113181 Q112478 Q112512 Q112270
## 1387                                                                
## 1388                                                                
## 1389                                                                
## 1390                                                                
## 1391                                                                
## 1392                                                                
##      Q111848 Q111580 Q111220 Q110740 Q109367 Q108950 Q109244 Q108855
## 1387                                                                
## 1388                                                                
## 1389                                                                
## 1390                                                                
## 1391                                                                
## 1392                                                                
##      Q108617 Q108856 Q108754 Q108342 Q108343 Q107869 Q107491 Q106993
## 1387                                                                
## 1388                                                                
## 1389                                                                
## 1390                                                                
## 1391                                                                
## 1392                                                                
##      Q106997 Q106272 Q106388 Q106389 Q106042 Q105840 Q105655 Q104996
## 1387                                                                
## 1388                                                                
## 1389                                                                
## 1390                                                                
## 1391                                                                
## 1392                                                                
##      Q103293 Q102906 Q102674 Q102687 Q102289 Q102089 Q101162 Q101163
## 1387                                                                
## 1388                                                                
## 1389                                                                
## 1390                                                                
## 1391                                                                
## 1392                                                                
##      Q101596 Q100689 Q100680 Q100562 Q99982 Q100010 Q99716 Q99581 Q99480
## 1387                                                                    
## 1388                                                                    
## 1389                                                                    
## 1390                                                                    
## 1391                                                                    
## 1392                                                                    
##      Q98869 Q98578 Q98059 Q98078 Q98197 Q96024
## 1387                                          
## 1388                                          
## 1389                                          
## 1390                                          
## 1391                                          
## 1392                                          
## 'data.frame':    1392 obs. of  20 variables:
##  $ USER_ID        : int  2 3 6 7 14 28 29 37 44 56 ...
##  $ YOB            : int  1985 1983 1995 1980 1980 1973 1968 1961 1989 1975 ...
##  $ Gender         : chr  "Female" "Male" "Male" "Female" ...
##  $ Income         : chr  "$25,001 - $50,000" "$50,000 - $74,999" "$75,000 - $100,000" "$50,000 - $74,999" ...
##  $ HouseholdStatus: chr  "Single (no kids)" "Married (w/kids)" "Single (no kids)" "Single (no kids)" ...
##  $ EducationLevel : chr  "Master's Degree" "Current Undergraduate" "Current K-12" "Master's Degree" ...
##  $ Q124742        : chr  "" "" "" "Yes" ...
##  $ Q124122        : chr  "Yes" "" "" "Yes" ...
##  $ Q123464        : chr  "No" "No" "" "No" ...
##  $ Q123621        : chr  "Yes" "" "" "Yes" ...
##  $ Q122769        : chr  "No" "Yes" "" "Yes" ...
##  $ Q122770        : chr  "No" "Yes" "" "Yes" ...
##  $ Q122771        : chr  "Public" "Public" "" "Public" ...
##  $ Q122120        : chr  "No" "No" "" "No" ...
##  $ Q121699        : chr  "Yes" "Yes" "No" "Yes" ...
##  $ Q121700        : chr  "Yes" "No" "No" "No" ...
##  $ Q120978        : chr  "Yes" "" "No" "Yes" ...
##  $ Q121011        : chr  "No" "" "Yes" "No" ...
##  $ Q120379        : chr  "Yes" "" "No" "Yes" ...
##  $ Q120650        : chr  "Yes" "" "Yes" "Yes" ...
## NULL
## 'data.frame':    1392 obs. of  20 variables:
##  $ Q120012: chr  "Yes" "No" "No" "Yes" ...
##  $ Q120014: chr  "Yes" "Yes" "Yes" "No" ...
##  $ Q118117: chr  "No" "" "" "Yes" ...
##  $ Q118237: chr  "Yes" "" "" "No" ...
##  $ Q116953: chr  "Yes" "Yes" "Yes" "Yes" ...
##  $ Q116601: chr  "Yes" "Yes" "" "No" ...
##  $ Q116448: chr  "Yes" "" "" "Yes" ...
##  $ Q116197: chr  "A.M." "P.M." "" "A.M." ...
##  $ Q115899: chr  "Me" "" "" "Me" ...
##  $ Q114961: chr  "Yes" "" "No" "No" ...
##  $ Q113584: chr  "People" "" "Technology" "People" ...
##  $ Q113181: chr  "Yes" "No" "Yes" "No" ...
##  $ Q112512: chr  "No" "" "Yes" "Yes" ...
##  $ Q108950: chr  "Cautious" "Cautious" "" "Cautious" ...
##  $ Q108617: chr  "" "No" "No" "No" ...
##  $ Q108342: chr  "In-person" "" "In-person" "Online" ...
##  $ Q107491: chr  "" "Yes" "Yes" "Yes" ...
##  $ Q106272: chr  "" "Yes" "Yes" "No" ...
##  $ Q106389: chr  "" "No" "Yes" "No" ...
##  $ Q104996: chr  "" "No" "Yes" "Yes" ...
## NULL
## 'data.frame':    1392 obs. of  21 variables:
##  $ Q102674: chr  "" "" "No" "No" ...
##  $ Q102687: chr  "" "" "No" "No" ...
##  $ Q102289: chr  "" "" "Yes" "No" ...
##  $ Q102089: chr  "" "Rent" "Own" "Own" ...
##  $ Q101162: chr  "" "Pessimist" "Optimist" "Optimist" ...
##  $ Q101163: chr  "" "Dad" "Mom" "Dad" ...
##  $ Q101596: chr  "" "" "No" "No" ...
##  $ Q100689: chr  "No" "" "No" "No" ...
##  $ Q100680: chr  "Yes" "" "Yes" "Yes" ...
##  $ Q100562: chr  "Yes" "Yes" "Yes" "Yes" ...
##  $ Q99982 : chr  "" "" "Nope" "Nope" ...
##  $ Q100010: chr  "" "" "No" "Yes" ...
##  $ Q99716 : chr  "" "" "No" "No" ...
##  $ Q99581 : chr  "" "" "No" "No" ...
##  $ Q99480 : chr  "" "" "Yes" "No" ...
##  $ Q98869 : chr  "Yes" "Yes" "Yes" "Yes" ...
##  $ Q98578 : chr  "" "" "No" "No" ...
##  $ Q98059 : chr  "" "Yes" "Yes" "Yes" ...
##  $ Q98078 : chr  "" "Yes" "No" "No" ...
##  $ Q98197 : chr  "" "No" "Yes" "No" ...
##  $ Q96024 : chr  "" "Yes" "Yes" "Yes" ...
## NULL
## Warning in myprint_str_df(obsDf): [list output truncated]
## [1] "Creating new feature: .pos..."
## [1] "Creating new feature: YOB.Age.fctr..."
## [1] "Creating new feature: YOB.Age.dff..."
## [1] "Creating new feature: Gender.fctr..."
## [1] "Creating new feature: Income.fctr..."
## [1] "Creating new feature: Hhold.fctr..."
## [1] "Creating new feature: Edn.fctr..."
## [1] "Creating new feature: Q124742.fctr..."
## [1] "Creating new feature: Q124122.fctr..."
## [1] "Creating new feature: Q123621.fctr..."
## [1] "Creating new feature: Q123464.fctr..."
## [1] "Creating new feature: Q122771.fctr..."
## [1] "Creating new feature: Q122770.fctr..."
## [1] "Creating new feature: Q122769.fctr..."
## [1] "Creating new feature: Q122120.fctr..."
## [1] "Creating new feature: Q121700.fctr..."
## [1] "Creating new feature: Q121699.fctr..."
## [1] "Creating new feature: Q121011.fctr..."
## [1] "Creating new feature: Q120978.fctr..."
## [1] "Creating new feature: Q120650.fctr..."
## [1] "Creating new feature: Q120472.fctr..."
## [1] "Creating new feature: Q120379.fctr..."
## [1] "Creating new feature: Q120194.fctr..."
## [1] "Creating new feature: Q120014.fctr..."
## [1] "Creating new feature: Q120012.fctr..."
## [1] "Creating new feature: Q119851.fctr..."
## [1] "Creating new feature: Q119650.fctr..."
## [1] "Creating new feature: Q119334.fctr..."
## [1] "Creating new feature: Q118892.fctr..."
## [1] "Creating new feature: Q118237.fctr..."
## [1] "Creating new feature: Q118233.fctr..."
## [1] "Creating new feature: Q118232.fctr..."
## [1] "Creating new feature: Q118117.fctr..."
## [1] "Creating new feature: Q117193.fctr..."
## [1] "Creating new feature: Q117186.fctr..."
## [1] "Creating new feature: Q116797.fctr..."
## [1] "Creating new feature: Q116881.fctr..."
## [1] "Creating new feature: Q116953.fctr..."
## [1] "Creating new feature: Q116601.fctr..."
## [1] "Creating new feature: Q116441.fctr..."
## [1] "Creating new feature: Q116448.fctr..."
## [1] "Creating new feature: Q116197.fctr..."
## [1] "Creating new feature: Q115602.fctr..."
## [1] "Creating new feature: Q115777.fctr..."
## [1] "Creating new feature: Q115610.fctr..."
## [1] "Creating new feature: Q115611.fctr..."
## [1] "Creating new feature: Q115899.fctr..."
## [1] "Creating new feature: Q115390.fctr..."
## [1] "Creating new feature: Q115195.fctr..."
## [1] "Creating new feature: Q114961.fctr..."
## [1] "Creating new feature: Q114748.fctr..."
## [1] "Creating new feature: Q114517.fctr..."
## [1] "Creating new feature: Q114386.fctr..."
## [1] "Creating new feature: Q114152.fctr..."
## [1] "Creating new feature: Q113992.fctr..."
## [1] "Creating new feature: Q113583.fctr..."
## [1] "Creating new feature: Q113584.fctr..."
## [1] "Creating new feature: Q113181.fctr..."
## [1] "Creating new feature: Q112478.fctr..."
## [1] "Creating new feature: Q112512.fctr..."
## [1] "Creating new feature: Q112270.fctr..."
## [1] "Creating new feature: Q111848.fctr..."
## [1] "Creating new feature: Q111580.fctr..."
## [1] "Creating new feature: Q111220.fctr..."
## [1] "Creating new feature: Q110740.fctr..."
## [1] "Creating new feature: Q109367.fctr..."
## [1] "Creating new feature: Q109244.fctr..."
## [1] "Creating new feature: Q108950.fctr..."
## [1] "Creating new feature: Q108855.fctr..."
## [1] "Creating new feature: Q108617.fctr..."
## [1] "Creating new feature: Q108856.fctr..."
## [1] "Creating new feature: Q108754.fctr..."
## [1] "Creating new feature: Q108342.fctr..."
## [1] "Creating new feature: Q108343.fctr..."
## [1] "Creating new feature: Q107869.fctr..."
## [1] "Creating new feature: Q107491.fctr..."
## [1] "Creating new feature: Q106993.fctr..."
## [1] "Creating new feature: Q106997.fctr..."
## [1] "Creating new feature: Q106272.fctr..."
## [1] "Creating new feature: Q106388.fctr..."
## [1] "Creating new feature: Q106389.fctr..."
## [1] "Creating new feature: Q106042.fctr..."
## [1] "Creating new feature: Q105840.fctr..."
## [1] "Creating new feature: Q105655.fctr..."
## [1] "Creating new feature: Q104996.fctr..."
## [1] "Creating new feature: Q103293.fctr..."
## [1] "Creating new feature: Q102906.fctr..."
## [1] "Creating new feature: Q102674.fctr..."
## [1] "Creating new feature: Q102687.fctr..."
## [1] "Creating new feature: Q102289.fctr..."
## [1] "Creating new feature: Q102089.fctr..."
## [1] "Creating new feature: Q101162.fctr..."
## [1] "Creating new feature: Q101163.fctr..."
## [1] "Creating new feature: Q101596.fctr..."
## [1] "Creating new feature: Q100689.fctr..."
## [1] "Creating new feature: Q100680.fctr..."
## [1] "Creating new feature: Q100562.fctr..."
## [1] "Creating new feature: Q100010.fctr..."
## [1] "Creating new feature: Q99982.fctr..."
## [1] "Creating new feature: Q99716.fctr..."
## [1] "Creating new feature: Q99581.fctr..."
## [1] "Creating new feature: Q99480.fctr..."
## [1] "Creating new feature: Q98869.fctr..."
## [1] "Creating new feature: Q98578.fctr..."
## [1] "Creating new feature: Q98197.fctr..."
## [1] "Creating new feature: Q98059.fctr..."
## [1] "Creating new feature: Q98078.fctr..."
## [1] "Creating new feature: Q96024.fctr..."
## [1] "Partition stats:"
## Loading required package: sqldf
## Loading required package: gsubfn
## Loading required package: proto
## Loading required package: RSQLite
## Loading required package: DBI
## Loading required package: tcltk
##        Party  .src   .n
## 1   Democrat Train 2951
## 2 Republican Train 2617
## 3       <NA>  Test 1392
##        Party  .src   .n
## 1   Democrat Train 2951
## 2 Republican Train 2617
## 3       <NA>  Test 1392
## Loading required package: RColorBrewer

##    .src   .n
## 1 Train 5568
## 2  Test 1392
## [1] "Running glbObsDropCondition filter: (glbObsAll[, \"Q109244\"] != \"\")"
## [1] "Partition stats:"
##        Party  .src   .n
## 1   Democrat Train 1171
## 2 Republican Train 1013
## 3       <NA>  Test  547
##        Party  .src   .n
## 1   Democrat Train 1171
## 2 Republican Train 1013
## 3       <NA>  Test  547

##    .src   .n
## 1 Train 2184
## 2  Test  547
## Loading required package: lazyeval
## Loading required package: gdata
## gdata: read.xls support for 'XLS' (Excel 97-2004) files ENABLED.
## 
## gdata: read.xls support for 'XLSX' (Excel 2007+) files ENABLED.
## 
## Attaching package: 'gdata'
## The following objects are masked from 'package:dplyr':
## 
##     combine, first, last
## The following object is masked from 'package:stats':
## 
##     nobs
## The following object is masked from 'package:utils':
## 
##     object.size
## [1] "Found 0 duplicates by all features:"
## NULL
##          label step_major step_minor label_minor    bgn    end elapsed
## 1  import.data          1          0           0  5.750 13.273   7.524
## 2 inspect.data          2          0           0 13.274     NA      NA

Step 2.0: inspect data

## Warning: Removed 547 rows containing non-finite values (stat_count).
## Loading required package: reshape2

##       Party.Democrat Party.Republican Party.NA
## Test              NA               NA      547
## Train           1171             1013       NA
##       Party.Democrat Party.Republican Party.NA
## Test              NA               NA        1
## Train      0.5361722        0.4638278       NA
## [1] "numeric data missing in : "
## YOB 
## 239 
## [1] "numeric data w/ 0s in : "
## YOB.Age.dff 
##         253 
## [1] "numeric data w/ Infs in : "
## named integer(0)
## [1] "numeric data w/ NaNs in : "
## named integer(0)
## [1] "string data missing in : "
##          Gender          Income HouseholdStatus  EducationLevel 
##              88             665             316             521 
##           Party         Q124742         Q124122         Q123464 
##              NA            2313            1954            1895 
##         Q123621         Q122769         Q122770         Q122771 
##            1928            1855            1758            1745 
##         Q122120         Q121699         Q121700         Q120978 
##            1719            1508            1543            1447 
##         Q121011         Q120379         Q120650         Q120472 
##            1447            1485            1367            1504 
##         Q120194         Q120012         Q120014         Q119334 
##            1657            1488            1641            1652 
##         Q119851         Q119650         Q118892         Q118117 
##            1458            1522            1493            1635 
##         Q118232         Q118233         Q118237         Q117186 
##            2006            1837            1789            1914 
##         Q117193         Q116797         Q116881         Q116953 
##            1868            1939            1978            1953 
##         Q116601         Q116441         Q116448         Q116197 
##            1847            1904            1927            1858 
##         Q115602         Q115777         Q115610         Q115611 
##            1844            1943            1870            1754 
##         Q115899         Q115390         Q114961         Q114748 
##            1956            1962            1905            1808 
##         Q115195         Q114517         Q114386         Q113992 
##            1880            1870            1951            1849 
##         Q114152         Q113583         Q113584         Q113181 
##            2031            1883            1901            1906 
##         Q112478         Q112512         Q112270         Q111848 
##            2067            2004            2050            1872 
##         Q111580         Q111220         Q110740         Q109367 
##            1993            1993            1949            2383 
##         Q108950         Q109244         Q108855         Q108617 
##            2346            2731            2379            2265 
##         Q108856         Q108754         Q108342         Q108343 
##            2388            2284            2262            2241 
##         Q107869         Q107491         Q106993         Q106997 
##            2177            2125            2100            2113 
##         Q106272         Q106388         Q106389         Q106042 
##            2084            2114            2140            2093 
##         Q105840         Q105655         Q104996         Q103293 
##            2167            2042            2019            2042 
##         Q102906         Q102674         Q102687         Q102289 
##            2116            2116            2038            2079 
##         Q102089         Q101162         Q101163         Q101596 
##            2052            2094            2152            2104 
##         Q100689         Q100680         Q100562          Q99982 
##            1969            2074            2080            2114 
##         Q100010          Q99716          Q99581          Q99480 
##            2033            2071            2010            2016 
##          Q98869          Q98578          Q98059          Q98078 
##            2088            2073            1984            2125 
##          Q98197          Q96024 
##            2084            2065
##        Party Party.fctr   .n
## 1   Democrat          D 1171
## 2 Republican          R 1013
## 3       <NA>       <NA>  547
## Warning: Removed 1 rows containing missing values (position_stack).

##       Party.fctr.D Party.fctr.R Party.fctr.NA
## Test            NA           NA           547
## Train         1171         1013            NA
##       Party.fctr.D Party.fctr.R Party.fctr.NA
## Test            NA           NA             1
## Train    0.5361722    0.4638278            NA

## [1] "elapsed Time (secs): 3.758000"
## Scale for 'y' is already present. Adding another scale for 'y', which
## will replace the existing scale.
## Scale for 'y' is already present. Adding another scale for 'y', which
## will replace the existing scale.

## [1] "elapsed Time (secs): 131.599000"
## [1] "elapsed Time (secs): 131.599000"
##          label step_major step_minor label_minor     bgn     end elapsed
## 2 inspect.data          2          0           0  13.274 150.664 137.391
## 3   scrub.data          2          1           1 150.665      NA      NA

Step 2.1: scrub data

```{r scrub.data, cache=FALSE, echo=FALSE, eval=myevlChunk(glbChunks, glbOut$pfx)}

## [1] "numeric data missing in : "
##        YOB Party.fctr 
##        239        547 
## [1] "numeric data w/ 0s in : "
## YOB.Age.dff 
##         253 
## [1] "numeric data w/ Infs in : "
## named integer(0)
## [1] "numeric data w/ NaNs in : "
## named integer(0)
## [1] "string data missing in : "
##          Gender          Income HouseholdStatus  EducationLevel 
##              88             665             316             521 
##           Party         Q124742         Q124122         Q123464 
##              NA            2313            1954            1895 
##         Q123621         Q122769         Q122770         Q122771 
##            1928            1855            1758            1745 
##         Q122120         Q121699         Q121700         Q120978 
##            1719            1508            1543            1447 
##         Q121011         Q120379         Q120650         Q120472 
##            1447            1485            1367            1504 
##         Q120194         Q120012         Q120014         Q119334 
##            1657            1488            1641            1652 
##         Q119851         Q119650         Q118892         Q118117 
##            1458            1522            1493            1635 
##         Q118232         Q118233         Q118237         Q117186 
##            2006            1837            1789            1914 
##         Q117193         Q116797         Q116881         Q116953 
##            1868            1939            1978            1953 
##         Q116601         Q116441         Q116448         Q116197 
##            1847            1904            1927            1858 
##         Q115602         Q115777         Q115610         Q115611 
##            1844            1943            1870            1754 
##         Q115899         Q115390         Q114961         Q114748 
##            1956            1962            1905            1808 
##         Q115195         Q114517         Q114386         Q113992 
##            1880            1870            1951            1849 
##         Q114152         Q113583         Q113584         Q113181 
##            2031            1883            1901            1906 
##         Q112478         Q112512         Q112270         Q111848 
##            2067            2004            2050            1872 
##         Q111580         Q111220         Q110740         Q109367 
##            1993            1993            1949            2383 
##         Q108950         Q109244         Q108855         Q108617 
##            2346            2731            2379            2265 
##         Q108856         Q108754         Q108342         Q108343 
##            2388            2284            2262            2241 
##         Q107869         Q107491         Q106993         Q106997 
##            2177            2125            2100            2113 
##         Q106272         Q106388         Q106389         Q106042 
##            2084            2114            2140            2093 
##         Q105840         Q105655         Q104996         Q103293 
##            2167            2042            2019            2042 
##         Q102906         Q102674         Q102687         Q102289 
##            2116            2116            2038            2079 
##         Q102089         Q101162         Q101163         Q101596 
##            2052            2094            2152            2104 
##         Q100689         Q100680         Q100562          Q99982 
##            1969            2074            2080            2114 
##         Q100010          Q99716          Q99581          Q99480 
##            2033            2071            2010            2016 
##          Q98869          Q98578          Q98059          Q98078 
##            2088            2073            1984            2125 
##          Q98197          Q96024 
##            2084            2065
##            label step_major step_minor label_minor     bgn     end elapsed
## 3     scrub.data          2          1           1 150.665 185.534   34.87
## 4 transform.data          2          2           2 185.535      NA      NA

Step 2.2: transform data

##              label step_major step_minor label_minor     bgn     end
## 4   transform.data          2          2           2 185.535 185.577
## 5 extract.features          3          0           0 185.577      NA
##   elapsed
## 4   0.042
## 5      NA

Step 3.0: extract features

##                       label step_major step_minor label_minor     bgn
## 5          extract.features          3          0           0 185.577
## 6 extract.features.datetime          3          1           1 185.597
##       end elapsed
## 5 185.596   0.019
## 6      NA      NA

Step 3.1: extract features datetime

##                           label step_major step_minor label_minor     bgn
## 1 extract.features.datetime.bgn          1          0           0 185.624
##   end elapsed
## 1  NA      NA
##                       label step_major step_minor label_minor     bgn
## 6 extract.features.datetime          3          1           1 185.597
## 7    extract.features.image          3          2           2 185.637
##       end elapsed
## 6 185.636   0.039
## 7      NA      NA

Step 3.2: extract features image

```{r extract.features.image, cache=FALSE, echo=FALSE, fig.height=5, fig.width=5, eval=myevlChunk(glbChunks, glbOut$pfx)}

##                        label step_major step_minor label_minor     bgn end
## 1 extract.features.image.bgn          1          0           0 185.668  NA
##   elapsed
## 1      NA
##                        label step_major step_minor label_minor     bgn
## 1 extract.features.image.bgn          1          0           0 185.668
## 2 extract.features.image.end          2          0           0 185.679
##       end elapsed
## 1 185.678    0.01
## 2      NA      NA
##                        label step_major step_minor label_minor     bgn
## 1 extract.features.image.bgn          1          0           0 185.668
## 2 extract.features.image.end          2          0           0 185.679
##       end elapsed
## 1 185.678    0.01
## 2      NA      NA
##                    label step_major step_minor label_minor     bgn     end
## 7 extract.features.image          3          2           2 185.637 185.689
## 8 extract.features.price          3          3           3 185.689      NA
##   elapsed
## 7   0.052
## 8      NA

Step 3.3: extract features price

##                        label step_major step_minor label_minor     bgn end
## 1 extract.features.price.bgn          1          0           0 185.714  NA
##   elapsed
## 1      NA
##                    label step_major step_minor label_minor     bgn     end
## 8 extract.features.price          3          3           3 185.689 185.723
## 9  extract.features.text          3          4           4 185.724      NA
##   elapsed
## 8   0.035
## 9      NA

Step 3.4: extract features text

##                       label step_major step_minor label_minor     bgn end
## 1 extract.features.text.bgn          1          0           0 185.779  NA
##   elapsed
## 1      NA
## Warning in rm(tmp_allobs_df): object 'tmp_allobs_df' not found
## Warning in rm(tmp_trnobs_df): object 'tmp_trnobs_df' not found
##                      label step_major step_minor label_minor     bgn
## 9    extract.features.text          3          4           4 185.724
## 10 extract.features.string          3          5           5 185.795
##        end elapsed
## 9  185.794    0.07
## 10      NA      NA

Step 3.5: extract features string

##                         label step_major step_minor label_minor     bgn
## 1 extract.features.string.bgn          1          0           0 185.831
##   end elapsed
## 1  NA      NA
##                                       label step_major step_minor
## 1               extract.features.string.bgn          1          0
## 2 extract.features.stringfactorize.str.vars          2          0
##   label_minor     bgn     end elapsed
## 1           0 185.831 185.842   0.011
## 2           0 185.842      NA      NA
##            Gender            Income   HouseholdStatus    EducationLevel 
##          "Gender"          "Income" "HouseholdStatus"  "EducationLevel" 
##             Party           Q124742           Q124122           Q123464 
##           "Party"         "Q124742"         "Q124122"         "Q123464" 
##           Q123621           Q122769           Q122770           Q122771 
##         "Q123621"         "Q122769"         "Q122770"         "Q122771" 
##           Q122120           Q121699           Q121700           Q120978 
##         "Q122120"         "Q121699"         "Q121700"         "Q120978" 
##           Q121011           Q120379           Q120650           Q120472 
##         "Q121011"         "Q120379"         "Q120650"         "Q120472" 
##           Q120194           Q120012           Q120014           Q119334 
##         "Q120194"         "Q120012"         "Q120014"         "Q119334" 
##           Q119851           Q119650           Q118892           Q118117 
##         "Q119851"         "Q119650"         "Q118892"         "Q118117" 
##           Q118232           Q118233           Q118237           Q117186 
##         "Q118232"         "Q118233"         "Q118237"         "Q117186" 
##           Q117193           Q116797           Q116881           Q116953 
##         "Q117193"         "Q116797"         "Q116881"         "Q116953" 
##           Q116601           Q116441           Q116448           Q116197 
##         "Q116601"         "Q116441"         "Q116448"         "Q116197" 
##           Q115602           Q115777           Q115610           Q115611 
##         "Q115602"         "Q115777"         "Q115610"         "Q115611" 
##           Q115899           Q115390           Q114961           Q114748 
##         "Q115899"         "Q115390"         "Q114961"         "Q114748" 
##           Q115195           Q114517           Q114386           Q113992 
##         "Q115195"         "Q114517"         "Q114386"         "Q113992" 
##           Q114152           Q113583           Q113584           Q113181 
##         "Q114152"         "Q113583"         "Q113584"         "Q113181" 
##           Q112478           Q112512           Q112270           Q111848 
##         "Q112478"         "Q112512"         "Q112270"         "Q111848" 
##           Q111580           Q111220           Q110740           Q109367 
##         "Q111580"         "Q111220"         "Q110740"         "Q109367" 
##           Q108950           Q109244           Q108855           Q108617 
##         "Q108950"         "Q109244"         "Q108855"         "Q108617" 
##           Q108856           Q108754           Q108342           Q108343 
##         "Q108856"         "Q108754"         "Q108342"         "Q108343" 
##           Q107869           Q107491           Q106993           Q106997 
##         "Q107869"         "Q107491"         "Q106993"         "Q106997" 
##           Q106272           Q106388           Q106389           Q106042 
##         "Q106272"         "Q106388"         "Q106389"         "Q106042" 
##           Q105840           Q105655           Q104996           Q103293 
##         "Q105840"         "Q105655"         "Q104996"         "Q103293" 
##           Q102906           Q102674           Q102687           Q102289 
##         "Q102906"         "Q102674"         "Q102687"         "Q102289" 
##           Q102089           Q101162           Q101163           Q101596 
##         "Q102089"         "Q101162"         "Q101163"         "Q101596" 
##           Q100689           Q100680           Q100562            Q99982 
##         "Q100689"         "Q100680"         "Q100562"          "Q99982" 
##           Q100010            Q99716            Q99581            Q99480 
##         "Q100010"          "Q99716"          "Q99581"          "Q99480" 
##            Q98869            Q98578            Q98059            Q98078 
##          "Q98869"          "Q98578"          "Q98059"          "Q98078" 
##            Q98197            Q96024              .src 
##          "Q98197"          "Q96024"            ".src"
##                      label step_major step_minor label_minor     bgn
## 10 extract.features.string          3          5           5 185.795
## 11    extract.features.end          3          6           6 185.865
##        end elapsed
## 10 185.864    0.07
## 11      NA      NA

Step 3.6: extract features end

## time trans    "bgn " "fit.data.training.all " "predict.data.new " "end " 
## 0.0000   multiple enabled transitions:  data.training.all data.new model.selected    firing:  data.training.all 
## 1.0000    1   2 1 0 0 
## 1.0000   multiple enabled transitions:  data.training.all data.new model.selected model.final data.training.all.prediction   firing:  data.new 
## 2.0000    2   1 1 1 0

##                   label step_major step_minor label_minor     bgn     end
## 11 extract.features.end          3          6           6 185.865 186.754
## 12  manage.missing.data          4          0           0 186.754      NA
##    elapsed
## 11   0.889
## 12      NA

Step 4.0: manage missing data

## [1] "numeric data missing in : "
##        YOB Party.fctr 
##        239        547 
## [1] "numeric data w/ 0s in : "
## YOB.Age.dff 
##         253 
## [1] "numeric data w/ Infs in : "
## named integer(0)
## [1] "numeric data w/ NaNs in : "
## named integer(0)
## [1] "string data missing in : "
##          Gender          Income HouseholdStatus  EducationLevel 
##              88             665             316             521 
##           Party         Q124742         Q124122         Q123464 
##              NA            2313            1954            1895 
##         Q123621         Q122769         Q122770         Q122771 
##            1928            1855            1758            1745 
##         Q122120         Q121699         Q121700         Q120978 
##            1719            1508            1543            1447 
##         Q121011         Q120379         Q120650         Q120472 
##            1447            1485            1367            1504 
##         Q120194         Q120012         Q120014         Q119334 
##            1657            1488            1641            1652 
##         Q119851         Q119650         Q118892         Q118117 
##            1458            1522            1493            1635 
##         Q118232         Q118233         Q118237         Q117186 
##            2006            1837            1789            1914 
##         Q117193         Q116797         Q116881         Q116953 
##            1868            1939            1978            1953 
##         Q116601         Q116441         Q116448         Q116197 
##            1847            1904            1927            1858 
##         Q115602         Q115777         Q115610         Q115611 
##            1844            1943            1870            1754 
##         Q115899         Q115390         Q114961         Q114748 
##            1956            1962            1905            1808 
##         Q115195         Q114517         Q114386         Q113992 
##            1880            1870            1951            1849 
##         Q114152         Q113583         Q113584         Q113181 
##            2031            1883            1901            1906 
##         Q112478         Q112512         Q112270         Q111848 
##            2067            2004            2050            1872 
##         Q111580         Q111220         Q110740         Q109367 
##            1993            1993            1949            2383 
##         Q108950         Q109244         Q108855         Q108617 
##            2346            2731            2379            2265 
##         Q108856         Q108754         Q108342         Q108343 
##            2388            2284            2262            2241 
##         Q107869         Q107491         Q106993         Q106997 
##            2177            2125            2100            2113 
##         Q106272         Q106388         Q106389         Q106042 
##            2084            2114            2140            2093 
##         Q105840         Q105655         Q104996         Q103293 
##            2167            2042            2019            2042 
##         Q102906         Q102674         Q102687         Q102289 
##            2116            2116            2038            2079 
##         Q102089         Q101162         Q101163         Q101596 
##            2052            2094            2152            2104 
##         Q100689         Q100680         Q100562          Q99982 
##            1969            2074            2080            2114 
##         Q100010          Q99716          Q99581          Q99480 
##            2033            2071            2010            2016 
##          Q98869          Q98578          Q98059          Q98078 
##            2088            2073            1984            2125 
##          Q98197          Q96024 
##            2084            2065
## [1] "numeric data missing in : "
##        YOB Party.fctr 
##        239        547 
## [1] "numeric data w/ 0s in : "
## YOB.Age.dff 
##         253 
## [1] "numeric data w/ Infs in : "
## named integer(0)
## [1] "numeric data w/ NaNs in : "
## named integer(0)
## [1] "string data missing in : "
##          Gender          Income HouseholdStatus  EducationLevel 
##              88             665             316             521 
##           Party         Q124742         Q124122         Q123464 
##              NA            2313            1954            1895 
##         Q123621         Q122769         Q122770         Q122771 
##            1928            1855            1758            1745 
##         Q122120         Q121699         Q121700         Q120978 
##            1719            1508            1543            1447 
##         Q121011         Q120379         Q120650         Q120472 
##            1447            1485            1367            1504 
##         Q120194         Q120012         Q120014         Q119334 
##            1657            1488            1641            1652 
##         Q119851         Q119650         Q118892         Q118117 
##            1458            1522            1493            1635 
##         Q118232         Q118233         Q118237         Q117186 
##            2006            1837            1789            1914 
##         Q117193         Q116797         Q116881         Q116953 
##            1868            1939            1978            1953 
##         Q116601         Q116441         Q116448         Q116197 
##            1847            1904            1927            1858 
##         Q115602         Q115777         Q115610         Q115611 
##            1844            1943            1870            1754 
##         Q115899         Q115390         Q114961         Q114748 
##            1956            1962            1905            1808 
##         Q115195         Q114517         Q114386         Q113992 
##            1880            1870            1951            1849 
##         Q114152         Q113583         Q113584         Q113181 
##            2031            1883            1901            1906 
##         Q112478         Q112512         Q112270         Q111848 
##            2067            2004            2050            1872 
##         Q111580         Q111220         Q110740         Q109367 
##            1993            1993            1949            2383 
##         Q108950         Q109244         Q108855         Q108617 
##            2346            2731            2379            2265 
##         Q108856         Q108754         Q108342         Q108343 
##            2388            2284            2262            2241 
##         Q107869         Q107491         Q106993         Q106997 
##            2177            2125            2100            2113 
##         Q106272         Q106388         Q106389         Q106042 
##            2084            2114            2140            2093 
##         Q105840         Q105655         Q104996         Q103293 
##            2167            2042            2019            2042 
##         Q102906         Q102674         Q102687         Q102289 
##            2116            2116            2038            2079 
##         Q102089         Q101162         Q101163         Q101596 
##            2052            2094            2152            2104 
##         Q100689         Q100680         Q100562          Q99982 
##            1969            2074            2080            2114 
##         Q100010          Q99716          Q99581          Q99480 
##            2033            2071            2010            2016 
##          Q98869          Q98578          Q98059          Q98078 
##            2088            2073            1984            2125 
##          Q98197          Q96024 
##            2084            2065
##                  label step_major step_minor label_minor     bgn     end
## 12 manage.missing.data          4          0           0 186.754 187.379
## 13        cluster.data          5          0           0 187.380      NA
##    elapsed
## 12   0.626
## 13      NA

Step 5.0: cluster data

```{r cluster.data, cache=FALSE, echo=FALSE, eval=myevlChunk(glbChunks, glbOut$pfx)}

## Loading required package: proxy
## 
## Attaching package: 'proxy'
## The following objects are masked from 'package:stats':
## 
##     as.dist, dist
## The following object is masked from 'package:base':
## 
##     as.matrix
## Loading required package: dynamicTreeCut
## Loading required package: entropy
## Loading required package: tidyr
## Loading required package: ggdendro
## [1] "Clustering features: "
## Warning in cor(data.matrix(glbObsAll[glbObsAll$.src == "Train",
## glbFeatsCluster]), : the standard deviation is zero
##               abs.cor.y
## Q113181.fctr 0.04357559
## Q102089.fctr 0.04804567
## Q100689.fctr 0.05185690
## Q113583.fctr 0.05306280
## Q101163.fctr 0.07163663
## [1] "    .rnorm cor: 0.0268"
## [1] "  Clustering entropy measure: Party.fctr"
## [1] "glbObsAll Entropy: 0.6905"
##   Q109244.fctr .clusterid Q109244.fctr.clusterid    D    R .entropy .knt
## 1           NA          1                   NA_1 1171 1013 0.690528 2184
## [1] "glbObsAll$Q109244.fctr Entropy: 0.6905 (100.0000 pct)"
## [1] "Category: NA"
## [1] "max distance(0.9810) pair:"
##      USER_ID Party.fctr Q109244.fctr Q124742.fctr Q124122.fctr
## 5090    6355          R           NA          Yes          Yes
## 6014    2335       <NA>           NA           NA           NA
##      Q123621.fctr Q123464.fctr Q122771.fctr Q122770.fctr Q122769.fctr
## 5090           No           No           Pc          Yes          Yes
## 6014           NA           NA           NA           NA           NA
##      Q122120.fctr Q121700.fctr Q121699.fctr Q121011.fctr Q120978.fctr
## 5090           No          Yes          Yes          Yes           No
## 6014           NA           NA           NA           NA           NA
##      Q120650.fctr Q120472.fctr Q120379.fctr Q120194.fctr Q120014.fctr
## 5090          Yes      Science           No  Study first           No
## 6014           NA           NA           NA           NA           NA
##      Q120012.fctr Q119851.fctr Q119650.fctr Q119334.fctr Q118892.fctr
## 5090           No          Yes       Giving          Yes          Yes
## 6014           NA           NA           NA           NA           NA
##      Q118237.fctr Q118233.fctr Q118232.fctr Q118117.fctr   Q117193.fctr
## 5090          Yes          Yes           Id          Yes Standard hours
## 6014           NA           NA           NA           NA             NA
##      Q117186.fctr Q116797.fctr Q116881.fctr Q116953.fctr Q116601.fctr
## 5090  Cool headed          Yes        Happy          Yes          Yes
## 6014           NA           NA           NA           NA           NA
##      Q116441.fctr Q116448.fctr Q116197.fctr Q115602.fctr Q115777.fctr
## 5090           No          Yes         P.M.          Yes          End
## 6014           NA           NA         P.M.           NA           NA
##      Q115610.fctr Q115611.fctr Q115899.fctr Q115390.fctr Q115195.fctr
## 5090          Yes           No           Me           No          Yes
## 6014           NA           NA           NA           NA           NA
##      Q114961.fctr Q114748.fctr Q114517.fctr Q114386.fctr Q114152.fctr
## 5090          Yes          Yes           No   Mysterious           NA
## 6014           NA           NA           NA           NA           NA
##      Q113992.fctr Q113583.fctr Q113584.fctr Q113181.fctr Q112478.fctr
## 5090           NA           NA           NA           NA           NA
## 6014           NA           NA           NA           NA          Yes
##      Q112512.fctr Q112270.fctr Q111848.fctr Q111580.fctr Q111220.fctr
## 5090           NA           NA           NA           NA           NA
## 6014          Yes           No          Yes   Supportive           No
##      Q110740.fctr Q109367.fctr Q109244.fctr.1 Q108950.fctr Q108855.fctr
## 5090           NA           NA             NA           NA           NA
## 6014           PC           NA             NA     Cautious       Umm...
##      Q108617.fctr Q108856.fctr Q108754.fctr Q108342.fctr Q108343.fctr
## 5090           NA           NA           NA           NA           NA
## 6014           No        Space           No       Online          Yes
##      Q107869.fctr Q107491.fctr Q106993.fctr Q106997.fctr Q106272.fctr
## 5090           NA           NA           NA           NA           NA
## 6014           No          Yes          Yes           Yy          Yes
##      Q106388.fctr Q106389.fctr Q106042.fctr Q105840.fctr Q105655.fctr
## 5090           NA           NA           NA           NA           NA
## 6014           No           No          Yes           No          Yes
##      Q104996.fctr Q103293.fctr Q102906.fctr Q102674.fctr Q102687.fctr
## 5090           NA           NA           NA           NA           NA
## 6014           No          Yes           No           No          Yes
##      Q102289.fctr Q102089.fctr Q101162.fctr Q101163.fctr Q101596.fctr
## 5090           NA           NA           NA           NA           NA
## 6014           No          Own    Pessimist          Dad          Yes
##      Q100689.fctr Q100680.fctr Q100562.fctr Q100010.fctr Q99982.fctr
## 5090           NA           NA           NA           NA          NA
## 6014          Yes          Yes           No          Yes        Nope
##      Q99716.fctr Q99581.fctr Q99480.fctr Q98869.fctr Q98578.fctr
## 5090          NA          NA          NA          NA          NA
## 6014          No          No         Yes          NA          NA
##      Q98197.fctr Q98059.fctr Q98078.fctr Q96024.fctr
## 5090          NA          NA          NA          NA
## 6014          NA          NA          NA         Yes
## [1] "min distance(0.9648) pair:"
##      USER_ID Party.fctr Q109244.fctr Q124742.fctr Q124122.fctr
## 5901    1696       <NA>           NA           NA           NA
## 6327    3843       <NA>           NA           NA           NA
##      Q123621.fctr Q123464.fctr Q122771.fctr Q122770.fctr Q122769.fctr
## 5901           NA           NA           NA           NA           NA
## 6327           NA           NA           NA           NA           NA
##      Q122120.fctr Q121700.fctr Q121699.fctr Q121011.fctr Q120978.fctr
## 5901           NA           NA           NA           NA           NA
## 6327           NA           NA           NA           NA           NA
##      Q120650.fctr Q120472.fctr Q120379.fctr Q120194.fctr Q120014.fctr
## 5901           NA           NA           NA           NA           NA
## 6327           NA           NA           NA           NA           NA
##      Q120012.fctr Q119851.fctr Q119650.fctr Q119334.fctr Q118892.fctr
## 5901           NA           NA           NA           NA           NA
## 6327           NA           NA           NA           NA           NA
##      Q118237.fctr Q118233.fctr Q118232.fctr Q118117.fctr Q117193.fctr
## 5901           NA           NA           NA           NA           NA
## 6327           NA           NA           NA           NA           NA
##      Q117186.fctr Q116797.fctr Q116881.fctr Q116953.fctr Q116601.fctr
## 5901           NA           NA           NA           NA           NA
## 6327           NA           NA           NA           NA           NA
##      Q116441.fctr Q116448.fctr Q116197.fctr Q115602.fctr Q115777.fctr
## 5901           NA           NA           NA           NA           NA
## 6327           NA           NA           NA           NA           NA
##      Q115610.fctr Q115611.fctr Q115899.fctr Q115390.fctr Q115195.fctr
## 5901           NA           NA           NA           NA           NA
## 6327           NA           NA           NA           NA           NA
##      Q114961.fctr Q114748.fctr Q114517.fctr Q114386.fctr Q114152.fctr
## 5901           NA           NA           NA           NA           NA
## 6327           NA           NA           NA           NA           NA
##      Q113992.fctr Q113583.fctr Q113584.fctr Q113181.fctr Q112478.fctr
## 5901           NA           NA           NA           NA           NA
## 6327           NA           NA           NA           NA           NA
##      Q112512.fctr Q112270.fctr Q111848.fctr Q111580.fctr Q111220.fctr
## 5901           NA           NA           NA    Demanding           NA
## 6327           NA           NA           NA           NA           NA
##      Q110740.fctr Q109367.fctr Q109244.fctr.1 Q108950.fctr Q108855.fctr
## 5901           NA           NA             NA           NA           NA
## 6327          Mac           NA             NA           NA           NA
##      Q108617.fctr Q108856.fctr Q108754.fctr Q108342.fctr Q108343.fctr
## 5901           No    Socialize           NA           NA           NA
## 6327           NA           NA           NA           NA           NA
##      Q107869.fctr Q107491.fctr Q106993.fctr Q106997.fctr Q106272.fctr
## 5901          Yes           NA           NA           NA           NA
## 6327           No           No           NA           Gr           NA
##      Q106388.fctr Q106389.fctr Q106042.fctr Q105840.fctr Q105655.fctr
## 5901           NA           NA           NA           NA           NA
## 6327           NA           NA           NA           NA           NA
##      Q104996.fctr Q103293.fctr Q102906.fctr Q102674.fctr Q102687.fctr
## 5901           NA           NA           NA           NA           NA
## 6327          Yes           NA           No           No           No
##      Q102289.fctr Q102089.fctr Q101162.fctr Q101163.fctr Q101596.fctr
## 5901           NA           NA           NA          Mom           NA
## 6327           No           NA    Pessimist          Mom           NA
##      Q100689.fctr Q100680.fctr Q100562.fctr Q100010.fctr Q99982.fctr
## 5901           NA           NA           NA           NA          NA
## 6327           NA           NA           NA           NA          NA
##      Q99716.fctr Q99581.fctr Q99480.fctr Q98869.fctr Q98578.fctr
## 5901          NA          NA          NA          NA          NA
## 6327          NA          NA          NA          NA          NA
##      Q98197.fctr Q98059.fctr Q98078.fctr Q96024.fctr
## 5901          NA  Only-child          NA          NA
## 6327          NA          NA          NA          NA
##   Q109244.fctr .clusterid Q109244.fctr.clusterid   D   R  .entropy .knt
## 1           NA          1                   NA_1 381 338 0.6913578  719
## 2           NA          2                   NA_2 303 277 0.6921421  580
## 3           NA          3                   NA_3 282 212 0.6830738  494
## 4           NA          4                   NA_4 205 186 0.6919661  391
## [1] "glbObsAll$Q109244.fctr$.clusterid Entropy: 0.6898 (99.8947 pct)"
##                      label step_major step_minor label_minor     bgn
## 13            cluster.data          5          0           0 187.380
## 14 partition.data.training          6          0           0 245.044
##        end elapsed
## 13 245.043  57.663
## 14      NA      NA

Step 6.0: partition data training

## [1] "partition.data.training chunk: setup: elapsed: 0.00 secs"
## [1] "partition.data.training chunk: strata_mtrx complete: elapsed: 0.09 secs"
## [1] "partition.data.training chunk: obs_freq_df complete: elapsed: 0.09 secs"
## [1] "lclgetMatrixSimilarity: duration: 14.373000 secs"
## Loading required package: sampling
## 
## Attaching package: 'sampling'
## The following object is masked from 'package:caret':
## 
##     cluster
## Stratum 1 
## 
## Population total and number of selected units: 1171 235 
## Stratum 2 
## 
## Population total and number of selected units: 1013 203 
## Number of strata  2 
## Total number of selected units 438 
## [1] "lclgetMatrixSimilarity: duration: 10.545000 secs"
## [1] "lclgetMatrixSimilarity: duration: 4.019000 secs"
## [1] "lclgetMatrixSimilarity: duration: 3.618000 secs"
## [1] "lclgetMatrixSimilarity: duration: 8.807000 secs"
## Warning: Removed 6 rows containing missing values (geom_path).
## geom_path: Each group consists of only one observation. Do you need to
## adjust the group aesthetic?
## Warning: Removed 12 rows containing missing values (geom_point).

## [1] "Similarity of partitions:"
##         cor cosineSmy obs.x obs.y
## 1 0.9999863 0.8824816   OOB   Fit
## 2 0.9999864 0.9177603   OOB   New
## 3 0.9999864 0.8303240   Fit   New
## [1] "partition.data.training chunk: Fit/OOB partition complete: elapsed: 42.68 secs"
##     Party.Democrat Party.Republican Party.NA
##                 NA               NA      547
## Fit            936              810       NA
## OOB            235              203       NA
##     Party.Democrat Party.Republican Party.NA
##                 NA               NA        1
## Fit      0.5360825        0.4639175       NA
## OOB      0.5365297        0.4634703       NA
##   Q109244.fctr .n.Fit .n.OOB .n.Tst .freqRatio.Fit .freqRatio.OOB
## 1           NA   1746    438    547              1              1
##   .freqRatio.Tst
## 1              1
## [1] "glbObsAll: "
## [1] 2731  222
## [1] "glbObsTrn: "
## [1] 2184  222
## [1] "glbObsFit: "
## [1] 1746  221
## [1] "glbObsOOB: "
## [1] 438 221
## [1] "glbObsNew: "
## [1] 547 221
## [1] "partition.data.training chunk: teardown: elapsed: 43.27 secs"
##                      label step_major step_minor label_minor     bgn
## 14 partition.data.training          6          0           0 245.044
## 15         select.features          7          0           0 288.391
##        end elapsed
## 14 288.391  43.347
## 15      NA      NA

Step 7.0: select features

```{r select.features, cache=FALSE, echo=FALSE, eval=myevlChunk(glbChunks, glbOut$pfx)}

## Warning in cor(data.matrix(entity_df[, sel_feats]), y =
## as.numeric(entity_df[, : the standard deviation is zero
## [1] "cor(Q98059.fctr, Q98078.fctr)=0.7770"
## [1] "cor(Party.fctr, Q98059.fctr)=-0.0411"
## [1] "cor(Party.fctr, Q98078.fctr)=-0.0435"
## Warning in myfind_cor_features(feats_df = glb_feats_df, obs_df =
## glbObsTrn, : Identified Q98059.fctr as highly correlated with Q98078.fctr
## [1] "cor(Q100562.fctr, Q100680.fctr)=0.7680"
## [1] "cor(Party.fctr, Q100562.fctr)=-0.0339"
## [1] "cor(Party.fctr, Q100680.fctr)=-0.0273"
## Warning in myfind_cor_features(feats_df = glb_feats_df, obs_df =
## glbObsTrn, : Identified Q100680.fctr as highly correlated with Q100562.fctr
## [1] "cor(Q113583.fctr, Q113584.fctr)=0.7653"
## [1] "cor(Party.fctr, Q113583.fctr)=-0.0531"
## [1] "cor(Party.fctr, Q113584.fctr)=-0.0342"
## Warning in myfind_cor_features(feats_df = glb_feats_df, obs_df =
## glbObsTrn, : Identified Q113584.fctr as highly correlated with Q113583.fctr
## [1] "cor(Q102674.fctr, Q102687.fctr)=0.7442"
## [1] "cor(Party.fctr, Q102674.fctr)=-0.0418"
## [1] "cor(Party.fctr, Q102687.fctr)=-0.0306"
## Warning in myfind_cor_features(feats_df = glb_feats_df, obs_df =
## glbObsTrn, : Identified Q102687.fctr as highly correlated with Q102674.fctr
## [1] "cor(Q100562.fctr, Q100689.fctr)=0.7006"
## [1] "cor(Party.fctr, Q100562.fctr)=-0.0339"
## [1] "cor(Party.fctr, Q100689.fctr)=-0.0519"
## Warning in myfind_cor_features(feats_df = glb_feats_df, obs_df =
## glbObsTrn, : Identified Q100562.fctr as highly correlated with Q100689.fctr
##                         cor.y exclude.as.feat    cor.y.abs   cor.high.X
## Gender.fctr      0.0909665772               0 0.0909665772         <NA>
## Q113181.fctr     0.0435755897               0 0.0435755897         <NA>
## .pos             0.0413144073               1 0.0413144073         <NA>
## USER_ID          0.0412669796               1 0.0412669796         <NA>
## Q120472.fctr     0.0373511418               0 0.0373511418         <NA>
## Q115611.fctr     0.0373054801               0 0.0373054801         <NA>
## Q120650.fctr     0.0358710311               0 0.0358710311         <NA>
## Q118237.fctr     0.0271389945               0 0.0271389945         <NA>
## .rnorm           0.0268489499               0 0.0268489499         <NA>
## Q122120.fctr     0.0234623979               0 0.0234623979         <NA>
## Q110740.fctr     0.0213122928               0 0.0213122928         <NA>
## Q122770.fctr     0.0203817957               0 0.0203817957         <NA>
## Q118117.fctr     0.0200889054               0 0.0200889054         <NA>
## Income.fctr      0.0178852251               0 0.0178852251         <NA>
## Q116441.fctr     0.0177162919               0 0.0177162919         <NA>
## Q118233.fctr     0.0176482250               0 0.0176482250         <NA>
## Q106272.fctr     0.0166660459               0 0.0166660459         <NA>
## Q119650.fctr     0.0154160890               0 0.0154160890         <NA>
## Q124742.fctr     0.0148384193               0 0.0148384193         <NA>
## Q122771.fctr     0.0146492330               0 0.0146492330         <NA>
## Q99480.fctr      0.0141594473               0 0.0141594473         <NA>
## Q116197.fctr     0.0130225570               0 0.0130225570         <NA>
## Q116881.fctr     0.0127923944               0 0.0127923944         <NA>
## Q101596.fctr     0.0122700322               0 0.0122700322         <NA>
## Q122769.fctr     0.0120730754               0 0.0120730754         <NA>
## Q108855.fctr     0.0116199609               0 0.0116199609         <NA>
## Q120014.fctr     0.0100200811               0 0.0100200811         <NA>
## Q119334.fctr     0.0097611771               0 0.0097611771         <NA>
## Q106993.fctr     0.0088906471               0 0.0088906471         <NA>
## Q107869.fctr     0.0084600631               0 0.0084600631         <NA>
## YOB              0.0065731919               1 0.0065731919         <NA>
## Q121011.fctr     0.0064795771               0 0.0064795771         <NA>
## Q117186.fctr     0.0061297032               0 0.0061297032         <NA>
## Q106997.fctr     0.0047472923               0 0.0047472923         <NA>
## YOB.Age.dff      0.0039888175               0 0.0039888175         <NA>
## Q108617.fctr     0.0034142713               0 0.0034142713         <NA>
## Q98197.fctr      0.0033385631               0 0.0033385631         <NA>
## Q106042.fctr     0.0028257871               0 0.0028257871         <NA>
## Q115777.fctr     0.0021874038               0 0.0021874038         <NA>
## Q123621.fctr     0.0020333068               0 0.0020333068         <NA>
## Q106388.fctr     0.0019532137               0 0.0019532137         <NA>
## Q114152.fctr    -0.0002141693               0 0.0002141693         <NA>
## Q124122.fctr    -0.0005523953               0 0.0005523953         <NA>
## Q120194.fctr    -0.0008725662               0 0.0008725662         <NA>
## Q116797.fctr    -0.0009782776               0 0.0009782776         <NA>
## Q105655.fctr    -0.0019537389               0 0.0019537389         <NA>
## Q115899.fctr    -0.0040294642               0 0.0040294642         <NA>
## Q116448.fctr    -0.0042193065               0 0.0042193065         <NA>
## Q117193.fctr    -0.0045436986               0 0.0045436986         <NA>
## Q108754.fctr    -0.0052510790               0 0.0052510790         <NA>
## Q108856.fctr    -0.0057486122               0 0.0057486122         <NA>
## YOB.Age.fctr    -0.0071871098               0 0.0071871098         <NA>
## Q123464.fctr    -0.0073497112               0 0.0073497112         <NA>
## Q99581.fctr     -0.0075725773               0 0.0075725773         <NA>
## Q114961.fctr    -0.0078051581               0 0.0078051581         <NA>
## Q104996.fctr    -0.0087935260               0 0.0087935260         <NA>
## Q108343.fctr    -0.0093294049               0 0.0093294049         <NA>
## Q120012.fctr    -0.0094832005               0 0.0094832005         <NA>
## Q120978.fctr    -0.0095190624               0 0.0095190624         <NA>
## .clusterid      -0.0103251988               1 0.0103251988         <NA>
## .clusterid.fctr -0.0103251988               0 0.0103251988         <NA>
## Q98578.fctr     -0.0127194176               0 0.0127194176         <NA>
## Q103293.fctr    -0.0127467568               0 0.0127467568         <NA>
## Q106389.fctr    -0.0127995068               0 0.0127995068         <NA>
## Q98869.fctr     -0.0141131536               0 0.0141131536         <NA>
## Q112512.fctr    -0.0148254430               0 0.0148254430         <NA>
## Q116953.fctr    -0.0150205968               0 0.0150205968         <NA>
## Q100010.fctr    -0.0157954167               0 0.0157954167         <NA>
## Q111220.fctr    -0.0161563341               0 0.0161563341         <NA>
## Q102906.fctr    -0.0162667502               0 0.0162667502         <NA>
## Q121700.fctr    -0.0162998394               0 0.0162998394         <NA>
## Q112478.fctr    -0.0164349791               0 0.0164349791         <NA>
## Q115610.fctr    -0.0179375585               0 0.0179375585         <NA>
## Q119851.fctr    -0.0188165770               0 0.0188165770         <NA>
## Q114517.fctr    -0.0194814883               0 0.0194814883         <NA>
## Q118892.fctr    -0.0197340603               0 0.0197340603         <NA>
## Q115602.fctr    -0.0202866077               0 0.0202866077         <NA>
## Q120379.fctr    -0.0203016988               0 0.0203016988         <NA>
## Q107491.fctr    -0.0205240116               0 0.0205240116         <NA>
## Q114748.fctr    -0.0209202111               0 0.0209202111         <NA>
## Q99982.fctr     -0.0215133899               0 0.0215133899         <NA>
## Q113992.fctr    -0.0222394292               0 0.0222394292         <NA>
## Q115390.fctr    -0.0224688906               0 0.0224688906         <NA>
## Q118232.fctr    -0.0257663213               0 0.0257663213         <NA>
## Q96024.fctr     -0.0265018957               0 0.0265018957         <NA>
## Q115195.fctr    -0.0271738479               0 0.0271738479         <NA>
## Q121699.fctr    -0.0273324911               0 0.0273324911         <NA>
## Q100680.fctr    -0.0273415528               0 0.0273415528 Q100562.fctr
## Q111580.fctr    -0.0274150724               0 0.0274150724         <NA>
## Q102289.fctr    -0.0285292574               0 0.0285292574         <NA>
## Q102687.fctr    -0.0306196219               0 0.0306196219 Q102674.fctr
## Q105840.fctr    -0.0307993280               0 0.0307993280         <NA>
## Q101162.fctr    -0.0310084074               0 0.0310084074         <NA>
## Q108950.fctr    -0.0317261524               0 0.0317261524         <NA>
## Q116601.fctr    -0.0325709549               0 0.0325709549         <NA>
## Q108342.fctr    -0.0332508344               0 0.0332508344         <NA>
## Q100562.fctr    -0.0338636276               0 0.0338636276 Q100689.fctr
## Q113584.fctr    -0.0341810079               0 0.0341810079 Q113583.fctr
## Q109367.fctr    -0.0343630284               0 0.0343630284         <NA>
## Q99716.fctr     -0.0374467543               0 0.0374467543         <NA>
## Hhold.fctr      -0.0382423557               0 0.0382423557         <NA>
## Q112270.fctr    -0.0396676511               0 0.0396676511         <NA>
## Q98059.fctr     -0.0411225217               0 0.0411225217  Q98078.fctr
## Q111848.fctr    -0.0412349958               0 0.0412349958         <NA>
## Q102674.fctr    -0.0417938234               0 0.0417938234         <NA>
## Q114386.fctr    -0.0423163811               0 0.0423163811         <NA>
## Q98078.fctr     -0.0434942851               0 0.0434942851         <NA>
## Q102089.fctr    -0.0480456671               0 0.0480456671         <NA>
## Edn.fctr        -0.0493632201               0 0.0493632201         <NA>
## Q100689.fctr    -0.0518568959               0 0.0518568959         <NA>
## Q113583.fctr    -0.0530628021               0 0.0530628021         <NA>
## Q101163.fctr    -0.0716366284               0 0.0716366284         <NA>
## Q109244.fctr               NA               0           NA         <NA>
##                 freqRatio percentUnique zeroVar   nzv is.cor.y.abs.low
## Gender.fctr      1.450753    0.13736264   FALSE FALSE            FALSE
## Q113181.fctr     3.968421    0.13736264   FALSE FALSE            FALSE
## .pos             1.000000  100.00000000   FALSE FALSE            FALSE
## USER_ID          1.000000  100.00000000   FALSE FALSE            FALSE
## Q120472.fctr     1.896389    0.13736264   FALSE FALSE            FALSE
## Q115611.fctr     2.705996    0.13736264   FALSE FALSE            FALSE
## Q120650.fctr     1.112016    0.13736264   FALSE FALSE            FALSE
## Q118237.fctr     3.284065    0.13736264   FALSE FALSE            FALSE
## .rnorm           1.000000  100.00000000   FALSE FALSE            FALSE
## Q122120.fctr     2.320883    0.13736264   FALSE FALSE             TRUE
## Q110740.fctr     4.361345    0.13736264   FALSE FALSE             TRUE
## Q122770.fctr     3.025974    0.13736264   FALSE FALSE             TRUE
## Q118117.fctr     2.587649    0.13736264   FALSE FALSE             TRUE
## Income.fctr      1.544160    0.32051282   FALSE FALSE             TRUE
## Q116441.fctr     3.578824    0.13736264   FALSE FALSE             TRUE
## Q118233.fctr     2.757576    0.13736264   FALSE FALSE             TRUE
## Q106272.fctr     4.321149    0.13736264   FALSE FALSE             TRUE
## Q119650.fctr     1.731915    0.13736264   FALSE FALSE             TRUE
## Q124742.fctr     8.808612    0.13736264   FALSE FALSE             TRUE
## Q122771.fctr     2.180534    0.13736264   FALSE FALSE             TRUE
## Q99480.fctr      3.603139    0.13736264   FALSE FALSE             TRUE
## Q116197.fctr     3.091858    0.13736264   FALSE FALSE             TRUE
## Q116881.fctr     3.634259    0.13736264   FALSE FALSE             TRUE
## Q101596.fctr     5.100304    0.13736264   FALSE FALSE             TRUE
## Q122769.fctr     3.500000    0.13736264   FALSE FALSE             TRUE
## Q108855.fctr    11.674847    0.13736264   FALSE FALSE             TRUE
## Q120014.fctr     2.410681    0.13736264   FALSE FALSE             TRUE
## Q119334.fctr     2.779193    0.13736264   FALSE FALSE             TRUE
## Q106993.fctr     3.783599    0.13736264   FALSE FALSE             TRUE
## Q107869.fctr     7.161826    0.13736264   FALSE FALSE             TRUE
## YOB              1.091743    3.43406593   FALSE FALSE             TRUE
## Q121011.fctr     2.049383    0.13736264   FALSE FALSE             TRUE
## Q117186.fctr     3.433409    0.13736264   FALSE FALSE             TRUE
## Q106997.fctr     6.438462    0.13736264   FALSE FALSE             TRUE
## YOB.Age.dff      1.098214    0.86996337   FALSE FALSE             TRUE
## Q108617.fctr     5.533742    0.13736264   FALSE FALSE             TRUE
## Q98197.fctr      5.296178    0.13736264   FALSE FALSE             TRUE
## Q106042.fctr     5.903915    0.13736264   FALSE FALSE             TRUE
## Q115777.fctr     4.316667    0.13736264   FALSE FALSE             TRUE
## Q123621.fctr     4.540059    0.13736264   FALSE FALSE             TRUE
## Q106388.fctr     4.481283    0.13736264   FALSE FALSE             TRUE
## Q114152.fctr     4.042929    0.13736264   FALSE FALSE             TRUE
## Q124122.fctr     4.057292    0.13736264   FALSE FALSE             TRUE
## Q120194.fctr     2.708163    0.13736264   FALSE FALSE             TRUE
## Q116797.fctr     4.049738    0.13736264   FALSE FALSE             TRUE
## Q105655.fctr     5.336634    0.13736264   FALSE FALSE             TRUE
## Q115899.fctr     4.610619    0.13736264   FALSE FALSE             TRUE
## Q116448.fctr     4.631420    0.13736264   FALSE FALSE             TRUE
## Q117193.fctr     3.419355    0.13736264   FALSE FALSE             TRUE
## Q108754.fctr     7.281746    0.13736264   FALSE FALSE             TRUE
## Q108856.fctr     8.883721    0.13736264   FALSE FALSE             TRUE
## YOB.Age.fctr     1.094828    0.41208791   FALSE FALSE             TRUE
## Q123464.fctr     2.323988    0.13736264   FALSE FALSE             TRUE
## Q99581.fctr      3.255578    0.13736264   FALSE FALSE             TRUE
## Q114961.fctr     4.412791    0.13736264   FALSE FALSE             TRUE
## Q104996.fctr     5.160256    0.13736264   FALSE FALSE             TRUE
## Q108343.fctr     7.047244    0.13736264   FALSE FALSE             TRUE
## Q120012.fctr     2.215613    0.13736264   FALSE FALSE             TRUE
## Q120978.fctr     1.991394    0.13736264   FALSE FALSE             TRUE
## .clusterid       1.239655    0.18315018   FALSE FALSE             TRUE
## .clusterid.fctr  1.239655    0.18315018   FALSE FALSE             TRUE
## Q98578.fctr      4.763689    0.13736264   FALSE FALSE             TRUE
## Q103293.fctr     5.266234    0.13736264   FALSE FALSE             TRUE
## Q106389.fctr     6.686275    0.13736264   FALSE FALSE             TRUE
## Q98869.fctr      4.231552    0.13736264   FALSE FALSE             TRUE
## Q112512.fctr     3.268994    0.13736264   FALSE FALSE             TRUE
## Q116953.fctr     3.706444    0.13736264   FALSE FALSE             TRUE
## Q100010.fctr     3.599558    0.13736264   FALSE FALSE             TRUE
## Q111220.fctr     3.793269    0.13736264   FALSE FALSE             TRUE
## Q102906.fctr     5.357827    0.13736264   FALSE FALSE             TRUE
## Q121700.fctr     1.584833    0.13736264   FALSE FALSE             TRUE
## Q112478.fctr     4.898507    0.13736264   FALSE FALSE             TRUE
## Q115610.fctr     2.595819    0.13736264   FALSE FALSE             TRUE
## Q119851.fctr     1.969543    0.13736264   FALSE FALSE             TRUE
## Q114517.fctr     3.109244    0.13736264   FALSE FALSE             TRUE
## Q118892.fctr     1.960591    0.13736264   FALSE FALSE             TRUE
## Q115602.fctr     2.656420    0.13736264   FALSE FALSE             TRUE
## Q120379.fctr     2.302326    0.13736264   FALSE FALSE             TRUE
## Q107491.fctr     3.898383    0.13736264   FALSE FALSE             TRUE
## Q114748.fctr     3.335664    0.13736264   FALSE FALSE             TRUE
## Q99982.fctr      5.702703    0.13736264   FALSE FALSE             TRUE
## Q113992.fctr     2.914172    0.13736264   FALSE FALSE             TRUE
## Q115390.fctr     4.036176    0.13736264   FALSE FALSE             TRUE
## Q118232.fctr     5.225490    0.13736264   FALSE FALSE             TRUE
## Q96024.fctr      5.104938    0.13736264   FALSE FALSE             TRUE
## Q115195.fctr     3.287912    0.13736264   FALSE FALSE            FALSE
## Q121699.fctr     1.704385    0.13736264   FALSE FALSE            FALSE
## Q100680.fctr     4.890533    0.13736264   FALSE FALSE            FALSE
## Q111580.fctr     4.118863    0.13736264   FALSE FALSE            FALSE
## Q102289.fctr     4.946429    0.13736264   FALSE FALSE            FALSE
## Q102687.fctr     5.698246    0.13736264   FALSE FALSE            FALSE
## Q105840.fctr     7.431034    0.13736264   FALSE FALSE            FALSE
## Q101162.fctr     5.211838    0.13736264   FALSE FALSE            FALSE
## Q108950.fctr     8.753488    0.13736264   FALSE FALSE            FALSE
## Q116601.fctr     2.490694    0.13736264   FALSE FALSE            FALSE
## Q108342.fctr     7.175299    0.13736264   FALSE FALSE            FALSE
## Q100562.fctr     4.191919    0.13736264   FALSE FALSE            FALSE
## Q113584.fctr     4.181058    0.13736264   FALSE FALSE            FALSE
## Q109367.fctr    11.134503    0.13736264   FALSE FALSE            FALSE
## Q99716.fctr      3.625821    0.13736264   FALSE FALSE            FALSE
## Hhold.fctr       1.896030    0.32051282   FALSE FALSE            FALSE
## Q112270.fctr     5.863799    0.13736264   FALSE FALSE            FALSE
## Q98059.fctr      2.971805    0.13736264   FALSE FALSE            FALSE
## Q111848.fctr     3.708229    0.13736264   FALSE FALSE            FALSE
## Q102674.fctr     4.988166    0.13736264   FALSE FALSE            FALSE
## Q114386.fctr     4.429395    0.13736264   FALSE FALSE            FALSE
## Q98078.fctr      6.255556    0.13736264   FALSE FALSE            FALSE
## Q102089.fctr     4.655271    0.13736264   FALSE FALSE            FALSE
## Edn.fctr         1.103359    0.36630037   FALSE FALSE            FALSE
## Q100689.fctr     4.553623    0.13736264   FALSE FALSE            FALSE
## Q113583.fctr     3.138655    0.13736264   FALSE FALSE            FALSE
## Q101163.fctr     6.202899    0.13736264   FALSE FALSE            FALSE
## Q109244.fctr     0.000000    0.04578755    TRUE  TRUE               NA
## Warning in myplot_scatter(plt_feats_df, "percentUnique", "freqRatio",
## colorcol_name = "nzv", : converting nzv to class:factor
## Warning: Removed 3 rows containing missing values (geom_point).

## Warning: Removed 3 rows containing missing values (geom_point).

## Warning: Removed 3 rows containing missing values (geom_point).

##              cor.y exclude.as.feat cor.y.abs cor.high.X freqRatio
## Q109244.fctr    NA               0        NA       <NA>         0
##              percentUnique zeroVar  nzv is.cor.y.abs.low
## Q109244.fctr    0.04578755    TRUE TRUE               NA
## Scale for 'y' is already present. Adding another scale for 'y', which
## will replace the existing scale.

## [1] "numeric data missing in : "
##        YOB Party.fctr 
##        239        547 
## [1] "numeric data w/ 0s in : "
## YOB.Age.dff 
##         253 
## [1] "numeric data w/ Infs in : "
## named integer(0)
## [1] "numeric data w/ NaNs in : "
## named integer(0)
## [1] "string data missing in : "
##          Gender          Income HouseholdStatus  EducationLevel 
##              88             665             316             521 
##           Party         Q124742         Q124122         Q123464 
##              NA            2313            1954            1895 
##         Q123621         Q122769         Q122770         Q122771 
##            1928            1855            1758            1745 
##         Q122120         Q121699         Q121700         Q120978 
##            1719            1508            1543            1447 
##         Q121011         Q120379         Q120650         Q120472 
##            1447            1485            1367            1504 
##         Q120194         Q120012         Q120014         Q119334 
##            1657            1488            1641            1652 
##         Q119851         Q119650         Q118892         Q118117 
##            1458            1522            1493            1635 
##         Q118232         Q118233         Q118237         Q117186 
##            2006            1837            1789            1914 
##         Q117193         Q116797         Q116881         Q116953 
##            1868            1939            1978            1953 
##         Q116601         Q116441         Q116448         Q116197 
##            1847            1904            1927            1858 
##         Q115602         Q115777         Q115610         Q115611 
##            1844            1943            1870            1754 
##         Q115899         Q115390         Q114961         Q114748 
##            1956            1962            1905            1808 
##         Q115195         Q114517         Q114386         Q113992 
##            1880            1870            1951            1849 
##         Q114152         Q113583         Q113584         Q113181 
##            2031            1883            1901            1906 
##         Q112478         Q112512         Q112270         Q111848 
##            2067            2004            2050            1872 
##         Q111580         Q111220         Q110740         Q109367 
##            1993            1993            1949            2383 
##         Q108950         Q109244         Q108855         Q108617 
##            2346            2731            2379            2265 
##         Q108856         Q108754         Q108342         Q108343 
##            2388            2284            2262            2241 
##         Q107869         Q107491         Q106993         Q106997 
##            2177            2125            2100            2113 
##         Q106272         Q106388         Q106389         Q106042 
##            2084            2114            2140            2093 
##         Q105840         Q105655         Q104996         Q103293 
##            2167            2042            2019            2042 
##         Q102906         Q102674         Q102687         Q102289 
##            2116            2116            2038            2079 
##         Q102089         Q101162         Q101163         Q101596 
##            2052            2094            2152            2104 
##         Q100689         Q100680         Q100562          Q99982 
##            1969            2074            2080            2114 
##         Q100010          Q99716          Q99581          Q99480 
##            2033            2071            2010            2016 
##          Q98869          Q98578          Q98059          Q98078 
##            2088            2073            1984            2125 
##          Q98197          Q96024            .lcn 
##            2084            2065             547
## [1] "glb_feats_df:"
## [1] 113  12
##                    id exclude.as.feat rsp_var
## Party.fctr Party.fctr            TRUE    TRUE
##                    id      cor.y exclude.as.feat  cor.y.abs cor.high.X
## USER_ID       USER_ID 0.04126698            TRUE 0.04126698       <NA>
## Party.fctr Party.fctr         NA            TRUE         NA       <NA>
##            freqRatio percentUnique zeroVar   nzv is.cor.y.abs.low
## USER_ID            1           100   FALSE FALSE            FALSE
## Party.fctr        NA            NA      NA    NA               NA
##            interaction.feat shapiro.test.p.value rsp_var_raw id_var
## USER_ID                <NA>                   NA       FALSE   TRUE
## Party.fctr             <NA>                   NA          NA     NA
##            rsp_var
## USER_ID         NA
## Party.fctr    TRUE
## [1] "glb_feats_df vs. glbObsAll: "
## character(0)
## [1] "glbObsAll vs. glb_feats_df: "
## character(0)
##              label step_major step_minor label_minor     bgn     end
## 15 select.features          7          0           0 288.391 291.195
## 16      fit.models          8          0           0 291.196      NA
##    elapsed
## 15   2.804
## 16      NA

Step 8.0: fit models

fit.models_0_chunk_df <- myadd_chunk(NULL, "fit.models_0_bgn", label.minor = "setup")
##              label step_major step_minor label_minor     bgn end elapsed
## 1 fit.models_0_bgn          1          0       setup 291.757  NA      NA
# load(paste0(glbOut$pfx, "dsk.RData"))

glbgetModelSelectFormula <- function() {
    model_evl_terms <- c(NULL)
    # min.aic.fit might not be avl
    lclMdlEvlCriteria <- 
        glbMdlMetricsEval[glbMdlMetricsEval %in% names(glb_models_df)]
    for (metric in lclMdlEvlCriteria)
        model_evl_terms <- c(model_evl_terms, 
                             ifelse(length(grep("max", metric)) > 0, "-", "+"), metric)
    if (glb_is_classification && glb_is_binomial)
        model_evl_terms <- c(model_evl_terms, "-", "opt.prob.threshold.OOB")
    model_sel_frmla <- as.formula(paste(c("~ ", model_evl_terms), collapse = " "))
    return(model_sel_frmla)
}

glbgetDisplayModelsDf <- function() {
    dsp_models_cols <- c("id", 
                    glbMdlMetricsEval[glbMdlMetricsEval %in% names(glb_models_df)],
                    grep("opt.", names(glb_models_df), fixed = TRUE, value = TRUE)) 
    dsp_models_df <- 
        #orderBy(glbgetModelSelectFormula(), glb_models_df)[, c("id", glbMdlMetricsEval)]
        orderBy(glbgetModelSelectFormula(), glb_models_df)[, dsp_models_cols]    
    nCvMdl <- sapply(glb_models_lst, function(mdl) nrow(mdl$results))
    nParams <- sapply(glb_models_lst, function(mdl) ifelse(mdl$method == "custom", 0, 
        nrow(subset(modelLookup(mdl$method), parameter != "parameter"))))
    
#     nCvMdl <- nCvMdl[names(nCvMdl) != "avNNet"]
#     nParams <- nParams[names(nParams) != "avNNet"]    
    
    if (length(cvMdlProblems <- nCvMdl[nCvMdl <= nParams]) > 0) {
        print("Cross Validation issues:")
        warning("Cross Validation issues:")        
        print(cvMdlProblems)
    }
    
    pltMdls <- setdiff(names(nCvMdl), names(cvMdlProblems))
    pltMdls <- setdiff(pltMdls, names(nParams[nParams == 0]))
    
    # length(pltMdls) == 21
    png(paste0(glbOut$pfx, "bestTune.png"), width = 480 * 2, height = 480 * 4)
    grid.newpage()
    pushViewport(viewport(layout = grid.layout(ceiling(length(pltMdls) / 2.0), 2)))
    pltIx <- 1
    for (mdlId in pltMdls) {
        print(ggplot(glb_models_lst[[mdlId]], highBestTune = TRUE) + labs(title = mdlId),   
              vp = viewport(layout.pos.row = ceiling(pltIx / 2.0), 
                            layout.pos.col = ((pltIx - 1) %% 2) + 1))  
        pltIx <- pltIx + 1
    }
    dev.off()

    if (all(row.names(dsp_models_df) != dsp_models_df$id))
        row.names(dsp_models_df) <- dsp_models_df$id
    return(dsp_models_df)
}
#glbgetDisplayModelsDf()

glb_get_predictions <- function(df, mdl_id, rsp_var, prob_threshold_def=NULL, verbose=FALSE) {
    mdl <- glb_models_lst[[mdl_id]]
    
    clmnNames <- mygetPredictIds(rsp_var, mdl_id)
    predct_var_name <- clmnNames$value        
    predct_prob_var_name <- clmnNames$prob
    predct_accurate_var_name <- clmnNames$is.acc
    predct_error_var_name <- clmnNames$err
    predct_erabs_var_name <- clmnNames$err.abs

    if (glb_is_regression) {
        df[, predct_var_name] <- predict(mdl, newdata=df, type="raw")
        if (verbose) print(myplot_scatter(df, glb_rsp_var, predct_var_name) + 
                  facet_wrap(reformulate(glbFeatsCategory), scales = "free") + 
                  stat_smooth(method="glm"))

        df[, predct_error_var_name] <- df[, predct_var_name] - df[, glb_rsp_var]
        if (verbose) print(myplot_scatter(df, predct_var_name, predct_error_var_name) + 
                  #facet_wrap(reformulate(glbFeatsCategory), scales = "free") + 
                  stat_smooth(method="auto"))
        if (verbose) print(myplot_scatter(df, glb_rsp_var, predct_error_var_name) + 
                  #facet_wrap(reformulate(glbFeatsCategory), scales = "free") + 
                  stat_smooth(method="glm"))
        
        df[, predct_erabs_var_name] <- abs(df[, predct_error_var_name])
        if (verbose) print(head(orderBy(reformulate(c("-", predct_erabs_var_name)), df)))
        
        df[, predct_accurate_var_name] <- (df[, glb_rsp_var] == df[, predct_var_name])
    }

    if (glb_is_classification && glb_is_binomial) {
        prob_threshold <- glb_models_df[glb_models_df$id == mdl_id, 
                                        "opt.prob.threshold.OOB"]
        if (is.null(prob_threshold) || is.na(prob_threshold)) {
            warning("Using default probability threshold: ", prob_threshold_def)
            if (is.null(prob_threshold <- prob_threshold_def))
                stop("Default probability threshold is NULL")
        }
        
        df[, predct_prob_var_name] <- predict(mdl, newdata = df, type = "prob")[, 2]
        df[, predct_var_name] <- 
                factor(levels(df[, glb_rsp_var])[
                    (df[, predct_prob_var_name] >=
                        prob_threshold) * 1 + 1], levels(df[, glb_rsp_var]))
    
#         if (verbose) print(myplot_scatter(df, glb_rsp_var, predct_var_name) + 
#                   facet_wrap(reformulate(glbFeatsCategory), scales = "free") + 
#                   stat_smooth(method="glm"))

        df[, predct_error_var_name] <- df[, predct_var_name] != df[, glb_rsp_var]
#         if (verbose) print(myplot_scatter(df, predct_var_name, predct_error_var_name) + 
#                   #facet_wrap(reformulate(glbFeatsCategory), scales = "free") + 
#                   stat_smooth(method="auto"))
#         if (verbose) print(myplot_scatter(df, glb_rsp_var, predct_error_var_name) + 
#                   #facet_wrap(reformulate(glbFeatsCategory), scales = "free") + 
#                   stat_smooth(method="glm"))
        
        # if prediction is a TP (true +ve), measure distance from 1.0
        tp <- which((df[, predct_var_name] == df[, glb_rsp_var]) &
                    (df[, predct_var_name] == levels(df[, glb_rsp_var])[2]))
        df[tp, predct_erabs_var_name] <- abs(1 - df[tp, predct_prob_var_name])
        #rowIx <- which.max(df[tp, predct_erabs_var_name]); df[tp, c(glbFeatsId, glb_rsp_var, predct_var_name, predct_prob_var_name, predct_erabs_var_name)][rowIx, ]
        
        # if prediction is a TN (true -ve), measure distance from 0.0
        tn <- which((df[, predct_var_name] == df[, glb_rsp_var]) &
                    (df[, predct_var_name] == levels(df[, glb_rsp_var])[1]))
        df[tn, predct_erabs_var_name] <- abs(0 - df[tn, predct_prob_var_name])
        #rowIx <- which.max(df[tn, predct_erabs_var_name]); df[tn, c(glbFeatsId, glb_rsp_var, predct_var_name, predct_prob_var_name, predct_erabs_var_name)][rowIx, ]
        
        # if prediction is a FP (flse +ve), measure distance from 0.0
        fp <- which((df[, predct_var_name] != df[, glb_rsp_var]) &
                    (df[, predct_var_name] == levels(df[, glb_rsp_var])[2]))
        df[fp, predct_erabs_var_name] <- abs(0 - df[fp, predct_prob_var_name])
        #rowIx <- which.max(df[fp, predct_erabs_var_name]); df[fp, c(glbFeatsId, glb_rsp_var, predct_var_name, predct_prob_var_name, predct_erabs_var_name)][rowIx, ]
        
        # if prediction is a FN (flse -ve), measure distance from 1.0
        fn <- which((df[, predct_var_name] != df[, glb_rsp_var]) &
                    (df[, predct_var_name] == levels(df[, glb_rsp_var])[1]))
        df[fn, predct_erabs_var_name] <- abs(1 - df[fn, predct_prob_var_name])
        #rowIx <- which.max(df[fn, predct_erabs_var_name]); df[fn, c(glbFeatsId, glb_rsp_var, predct_var_name, predct_prob_var_name, predct_erabs_var_name)][rowIx, ]

        
        if (verbose) print(head(orderBy(reformulate(c("-", predct_erabs_var_name)), df)))
        
        df[, predct_accurate_var_name] <- (df[, glb_rsp_var] == df[, predct_var_name])
    }    
    
    if (glb_is_classification && !glb_is_binomial) {
        df[, predct_var_name] <- predict(mdl, newdata = df, type = "raw")
        probCls <- predict(mdl, newdata = df, type = "prob")        
        df[, predct_prob_var_name] <- NA
        for (cls in names(probCls)) {
            mask <- (df[, predct_var_name] == cls)
            df[mask, predct_prob_var_name] <- probCls[mask, cls]
        }    
        if (verbose) print(myplot_histogram(df, predct_prob_var_name, 
                                            fill_col_name = predct_var_name))
        if (verbose) print(myplot_histogram(df, predct_prob_var_name, 
                                            facet_frmla = paste0("~", glb_rsp_var)))
        
        df[, predct_error_var_name] <- df[, predct_var_name] != df[, glb_rsp_var]
        
        # if prediction is erroneous, measure predicted class prob from actual class prob
        df[, predct_erabs_var_name] <- 0
        for (cls in names(probCls)) {
            mask <- (df[, glb_rsp_var] == cls) & (df[, predct_error_var_name])
            df[mask, predct_erabs_var_name] <- probCls[mask, cls]
        }    

        df[, predct_accurate_var_name] <- (df[, glb_rsp_var] == df[, predct_var_name])        
    }

    return(df)
}    

if (glb_is_classification && glb_is_binomial && 
        (length(unique(glbObsFit[, glb_rsp_var])) < 2))
    stop("glbObsFit$", glb_rsp_var, ": contains less than 2 unique values: ",
         paste0(unique(glbObsFit[, glb_rsp_var]), collapse=", "))

max_cor_y_x_vars <- orderBy(~ -cor.y.abs, 
        subset(glb_feats_df, (exclude.as.feat == 0) & !nzv & !is.cor.y.abs.low & 
                                is.na(cor.high.X)))[1:2, "id"]
max_cor_y_x_vars <- max_cor_y_x_vars[!is.na(max_cor_y_x_vars)]
if (length(max_cor_y_x_vars) < 2)
    max_cor_y_x_vars <- union(max_cor_y_x_vars, ".pos")

if (!is.null(glb_Baseline_mdl_var)) {
    if ((max_cor_y_x_vars[1] != glb_Baseline_mdl_var) & 
        (glb_feats_df[glb_feats_df$id == max_cor_y_x_vars[1], "cor.y.abs"] > 
         glb_feats_df[glb_feats_df$id == glb_Baseline_mdl_var, "cor.y.abs"]))
        stop(max_cor_y_x_vars[1], " has a higher correlation with ", glb_rsp_var, 
             " than the Baseline var: ", glb_Baseline_mdl_var)
}

glb_model_type <- ifelse(glb_is_regression, "regression", "classification")
    
# Model specs
# c("id.prefix", "method", "type",
#   # trainControl params
#   "preProc.method", "cv.n.folds", "cv.n.repeats", "summary.fn",
#   # train params
#   "metric", "metric.maximize", "tune.df")

# Baseline
if (!is.null(glb_Baseline_mdl_var)) {
    fit.models_0_chunk_df <- myadd_chunk(fit.models_0_chunk_df, 
                            paste0("fit.models_0_", "Baseline"), major.inc = FALSE,
                                    label.minor = "mybaseln_classfr")
    ret_lst <- myfit_mdl(mdl_id="Baseline", 
                         model_method="mybaseln_classfr",
                        indepVar=glb_Baseline_mdl_var,
                        rsp_var=glb_rsp_var,
                        fit_df=glbObsFit, OOB_df=glbObsOOB)
}    

# Most Frequent Outcome "MFO" model: mean(y) for regression
#   Not using caret's nullModel since model stats not avl
#   Cannot use rpart for multinomial classification since it predicts non-MFO
if (glb_is_classification) {
    fit.models_0_chunk_df <- myadd_chunk(fit.models_0_chunk_df, 
                                paste0("fit.models_0_", "MFO"), major.inc = FALSE,
                                        label.minor = "myMFO_classfr")

    ret_lst <- myfit_mdl(mdl_specs_lst = myinit_mdl_specs_lst(mdl_specs_lst = list(
        id.prefix = "MFO", type = glb_model_type, trainControl.method = "none",
        train.method = ifelse(glb_is_regression, "lm", "myMFO_classfr"))),
                            indepVar = ".rnorm", rsp_var = glb_rsp_var,
                            fit_df = glbObsFit, OOB_df = glbObsOOB)

        # "random" model - only for classification; 
        #   none needed for regression since it is same as MFO
    fit.models_0_chunk_df <- myadd_chunk(fit.models_0_chunk_df, 
                                paste0("fit.models_0_", "Random"), major.inc = FALSE,
                                        label.minor = "myrandom_classfr")

#stop(here"); glb2Sav(); all.equal(glb_models_df, sav_models_df)    
    ret_lst <- myfit_mdl(mdl_specs_lst = myinit_mdl_specs_lst(mdl_specs_lst = list(
        id.prefix = "Random", type = glb_model_type, trainControl.method = "none",
        train.method = "myrandom_classfr")),
                        indepVar = ".rnorm", rsp_var = glb_rsp_var,
                        fit_df = glbObsFit, OOB_df = glbObsOOB)
}
##              label step_major step_minor   label_minor     bgn     end
## 1 fit.models_0_bgn          1          0         setup 291.757 291.791
## 2 fit.models_0_MFO          1          1 myMFO_classfr 291.791      NA
##   elapsed
## 1   0.034
## 2      NA
## [1] "myfit_mdl: enter: 0.001000 secs"
## [1] "myfit_mdl: fitting model: MFO###myMFO_classfr"
## [1] "    indepVar: .rnorm"
## [1] "myfit_mdl: setup complete: 0.411000 secs"
## Fitting parameter = none on full training set
## [1] "in MFO.Classifier$fit"
## [1] "unique.vals:"
## [1] D R
## Levels: D R
## [1] "unique.prob:"
## y
##         D         R 
## 0.5360825 0.4639175 
## [1] "MFO.val:"
## [1] "D"
## [1] "myfit_mdl: train complete: 0.904000 secs"
##   parameter
## 1      none
##             Length Class      Mode     
## unique.vals 2      factor     numeric  
## unique.prob 2      -none-     numeric  
## MFO.val     1      -none-     character
## x.names     1      -none-     character
## xNames      1      -none-     character
## problemType 1      -none-     character
## tuneValue   1      data.frame list     
## obsLevels   2      -none-     character
## Warning in if (mdl_specs_lst[["train.method"]] == "glm")
## mydisplayOutliers(mdl, : the condition has length > 1 and only the first
## element will be used
## [1] "myfit_mdl: train diagnostics complete: 0.907000 secs"
## Loading required namespace: pROC
## [1] "entr MFO.Classifier$predict"
## [1] "exit MFO.Classifier$predict"
## Loading required package: ROCR
## Loading required package: gplots
## 
## Attaching package: 'gplots'
## The following object is masked from 'package:stats':
## 
##     lowess
## [1] "in MFO.Classifier$prob"
##           D         R
## 1 0.5360825 0.4639175
## 2 0.5360825 0.4639175
## 3 0.5360825 0.4639175
## 4 0.5360825 0.4639175
## 5 0.5360825 0.4639175
## 6 0.5360825 0.4639175

##          Prediction
## Reference   D   R
##         D 936   0
##         R 810   0
##       Accuracy          Kappa  AccuracyLower  AccuracyUpper   AccuracyNull 
##   5.360825e-01   0.000000e+00   5.123603e-01   5.596832e-01   5.360825e-01 
## AccuracyPValue  McnemarPValue 
##   5.098012e-01  9.827871e-178 
## [1] "entr MFO.Classifier$predict"
## [1] "exit MFO.Classifier$predict"
## [1] "in MFO.Classifier$prob"
##           D         R
## 1 0.5360825 0.4639175
## 2 0.5360825 0.4639175
## 3 0.5360825 0.4639175
## 4 0.5360825 0.4639175
## 5 0.5360825 0.4639175
## 6 0.5360825 0.4639175
##          Prediction
## Reference   D   R
##         D 235   0
##         R 203   0
##       Accuracy          Kappa  AccuracyLower  AccuracyUpper   AccuracyNull 
##   5.365297e-01   0.000000e+00   4.885756e-01   5.839872e-01   5.365297e-01 
## AccuracyPValue  McnemarPValue 
##   5.195666e-01   1.260484e-45 
## [1] "myfit_mdl: predict complete: 6.293000 secs"
##                    id  feats max.nTuningRuns min.elapsedtime.everything
## 1 MFO###myMFO_classfr .rnorm               0                      0.485
##   min.elapsedtime.final max.AUCpROC.fit max.Sens.fit max.Spec.fit
## 1                 0.004             0.5            1            0
##   max.AUCROCR.fit opt.prob.threshold.fit max.f.score.fit max.Accuracy.fit
## 1             0.5                    0.5               0        0.5360825
##   max.AccuracyLower.fit max.AccuracyUpper.fit max.Kappa.fit
## 1             0.5123603             0.5596832             0
##   max.AUCpROC.OOB max.Sens.OOB max.Spec.OOB max.AUCROCR.OOB
## 1             0.5            1            0             0.5
##   opt.prob.threshold.OOB max.f.score.OOB max.Accuracy.OOB
## 1                    0.5               0        0.5365297
##   max.AccuracyLower.OOB max.AccuracyUpper.OOB max.Kappa.OOB
## 1             0.4885756             0.5839872             0
## [1] "in MFO.Classifier$prob"
##           D         R
## 1 0.5360825 0.4639175
## 2 0.5360825 0.4639175
## 3 0.5360825 0.4639175
## 4 0.5360825 0.4639175
## 5 0.5360825 0.4639175
## 6 0.5360825 0.4639175
## [1] "myfit_mdl: exit: 6.338000 secs"
##                 label step_major step_minor      label_minor     bgn
## 2    fit.models_0_MFO          1          1    myMFO_classfr 291.791
## 3 fit.models_0_Random          1          2 myrandom_classfr 298.136
##       end elapsed
## 2 298.136   6.345
## 3      NA      NA
## [1] "myfit_mdl: enter: 0.001000 secs"
## [1] "myfit_mdl: fitting model: Random###myrandom_classfr"
## [1] "    indepVar: .rnorm"
## [1] "myfit_mdl: setup complete: 0.403000 secs"
## Fitting parameter = none on full training set
## [1] "myfit_mdl: train complete: 0.789000 secs"
##   parameter
## 1      none
##             Length Class      Mode     
## unique.vals 2      factor     numeric  
## unique.prob 2      table      numeric  
## xNames      1      -none-     character
## problemType 1      -none-     character
## tuneValue   1      data.frame list     
## obsLevels   2      -none-     character
## Warning in if (mdl_specs_lst[["train.method"]] == "glm")
## mydisplayOutliers(mdl, : the condition has length > 1 and only the first
## element will be used

## [1] "myfit_mdl: train diagnostics complete: 0.791000 secs"
## [1] "in Random.Classifier$prob"

##          Prediction
## Reference   D   R
##         D 936   0
##         R 810   0
##       Accuracy          Kappa  AccuracyLower  AccuracyUpper   AccuracyNull 
##   5.360825e-01   0.000000e+00   5.123603e-01   5.596832e-01   5.360825e-01 
## AccuracyPValue  McnemarPValue 
##   5.098012e-01  9.827871e-178 
## [1] "in Random.Classifier$prob"

##          Prediction
## Reference   D   R
##         D 235   0
##         R 203   0
##       Accuracy          Kappa  AccuracyLower  AccuracyUpper   AccuracyNull 
##   5.365297e-01   0.000000e+00   4.885756e-01   5.839872e-01   5.365297e-01 
## AccuracyPValue  McnemarPValue 
##   5.195666e-01   1.260484e-45 
## [1] "myfit_mdl: predict complete: 6.702000 secs"
##                          id  feats max.nTuningRuns
## 1 Random###myrandom_classfr .rnorm               0
##   min.elapsedtime.everything min.elapsedtime.final max.AUCpROC.fit
## 1                      0.381                 0.002       0.4916667
##   max.Sens.fit max.Spec.fit max.AUCROCR.fit opt.prob.threshold.fit
## 1    0.5277778    0.4555556       0.5138295                   0.55
##   max.f.score.fit max.Accuracy.fit max.AccuracyLower.fit
## 1               0        0.5360825             0.5123603
##   max.AccuracyUpper.fit max.Kappa.fit max.AUCpROC.OOB max.Sens.OOB
## 1             0.5596832             0       0.5576145     0.612766
##   max.Spec.OOB max.AUCROCR.OOB opt.prob.threshold.OOB max.f.score.OOB
## 1    0.5024631       0.5042029                   0.55               0
##   max.Accuracy.OOB max.AccuracyLower.OOB max.AccuracyUpper.OOB
## 1        0.5365297             0.4885756             0.5839872
##   max.Kappa.OOB
## 1             0
## [1] "in Random.Classifier$prob"
## [1] "myfit_mdl: exit: 7.419000 secs"
# Max.cor.Y
#   Check impact of cv
#       rpart is not a good candidate since caret does not optimize cp (only tuning parameter of rpart) well
fit.models_0_chunk_df <- myadd_chunk(fit.models_0_chunk_df, 
                        paste0("fit.models_0_", "Max.cor.Y.rcv.*X*"), major.inc = FALSE,
                                    label.minor = "glmnet")
##                            label step_major step_minor      label_minor
## 3            fit.models_0_Random          1          2 myrandom_classfr
## 4 fit.models_0_Max.cor.Y.rcv.*X*          1          3           glmnet
##       bgn     end elapsed
## 3 298.136 305.567   7.431
## 4 305.568      NA      NA
ret_lst <- myfit_mdl(mdl_specs_lst = myinit_mdl_specs_lst(mdl_specs_lst = list(
    id.prefix = "Max.cor.Y.rcv.1X1", type = glb_model_type, trainControl.method = "none",
    train.method = "glmnet")),
                    indepVar = max_cor_y_x_vars, rsp_var = glb_rsp_var, 
                    fit_df = glbObsFit, OOB_df = glbObsOOB)
## [1] "myfit_mdl: enter: 0.001000 secs"
## [1] "myfit_mdl: fitting model: Max.cor.Y.rcv.1X1###glmnet"
## [1] "    indepVar: Gender.fctr,Q101163.fctr"
## [1] "myfit_mdl: setup complete: 0.671000 secs"
## Loading required package: glmnet
## Loading required package: Matrix
## 
## Attaching package: 'Matrix'
## The following object is masked from 'package:tidyr':
## 
##     expand
## Loaded glmnet 2.0-5
## Fitting alpha = 0.1, lambda = 0.000983 on full training set
## [1] "myfit_mdl: train complete: 1.387000 secs"
##   alpha       lambda
## 1   0.1 0.0009825205

##             Length Class      Mode     
## a0           45    -none-     numeric  
## beta        180    dgCMatrix  S4       
## df           45    -none-     numeric  
## dim           2    -none-     numeric  
## lambda       45    -none-     numeric  
## dev.ratio    45    -none-     numeric  
## nulldev       1    -none-     numeric  
## npasses       1    -none-     numeric  
## jerr          1    -none-     numeric  
## offset        1    -none-     logical  
## classnames    2    -none-     character
## call          5    -none-     call     
## nobs          1    -none-     numeric  
## lambdaOpt     1    -none-     numeric  
## xNames        4    -none-     character
## problemType   1    -none-     character
## tuneValue     2    data.frame list     
## obsLevels     2    -none-     character
## [1] "min lambda > lambdaOpt:"
##     (Intercept)    Gender.fctrF    Gender.fctrM Q101163.fctrDad 
##     -0.31106828     -0.00973240      0.36620048      0.09363164 
## Q101163.fctrMom 
##     -0.60199303 
## [1] "max lambda < lambdaOpt:"
## [1] "Feats mismatch between coefs_left & rght:"
## [1] "(Intercept)"     "Gender.fctrF"    "Gender.fctrM"    "Q101163.fctrDad"
## [5] "Q101163.fctrMom"
## [1] "myfit_mdl: train diagnostics complete: 1.494000 secs"

## [1] "mypredict_mdl: maxMetricDf:"
##    threshold   f.score  accuracy
## 10      0.45 0.5557481 0.5595647
## 11      0.50 0.5557481 0.5595647

##          Prediction
## Reference   D   R
##         D 496 440
##         R 329 481
##       Accuracy          Kappa  AccuracyLower  AccuracyUpper   AccuracyNull 
##   5.595647e-01   1.226108e-01   5.359087e-01   5.830202e-01   5.360825e-01 
## AccuracyPValue  McnemarPValue 
##   2.586206e-02   7.287418e-05

## [1] "mypredict_mdl: maxMetricDf:"
##    threshold   f.score  accuracy
## 10      0.45 0.5421412 0.5410959
## 11      0.50 0.5421412 0.5410959

##          Prediction
## Reference   D   R
##         D 118 117
##         R  84 119
##       Accuracy          Kappa  AccuracyLower  AccuracyUpper   AccuracyNull 
##     0.54109589     0.08736757     0.49314387     0.58848926     0.53652968 
## AccuracyPValue  McnemarPValue 
##     0.44331935     0.02400145 
## [1] "myfit_mdl: predict complete: 6.789000 secs"
##                           id                    feats max.nTuningRuns
## 1 Max.cor.Y.rcv.1X1###glmnet Gender.fctr,Q101163.fctr               0
##   min.elapsedtime.everything min.elapsedtime.final max.AUCpROC.fit
## 1                       0.71                 0.025       0.5618708
##   max.Sens.fit max.Spec.fit max.AUCROCR.fit opt.prob.threshold.fit
## 1    0.5299145    0.5938272       0.5720013                    0.5
##   max.f.score.fit max.Accuracy.fit max.AccuracyLower.fit
## 1       0.5557481        0.5595647             0.5359087
##   max.AccuracyUpper.fit max.Kappa.fit max.AUCpROC.OOB max.Sens.OOB
## 1             0.5830202     0.1226108       0.5441673    0.5021277
##   max.Spec.OOB max.AUCROCR.OOB opt.prob.threshold.OOB max.f.score.OOB
## 1    0.5862069       0.5584215                    0.5       0.5421412
##   max.Accuracy.OOB max.AccuracyLower.OOB max.AccuracyUpper.OOB
## 1        0.5410959             0.4931439             0.5884893
##   max.Kappa.OOB
## 1    0.08736757
## [1] "myfit_mdl: exit: 6.854000 secs"
if (glbMdlCheckRcv) {
    # rcv_n_folds == 1 & rcv_n_repeats > 1 crashes
    for (rcv_n_folds in seq(3, glb_rcv_n_folds + 2, 2))
        for (rcv_n_repeats in seq(1, glb_rcv_n_repeats + 2, 2)) {
            
            # Experiment specific code to avoid caret crash
    #         lcl_tune_models_df <- rbind(data.frame()
    #                             ,data.frame(method = "glmnet", parameter = "alpha", 
    #                                         vals = "0.100 0.325 0.550 0.775 1.000")
    #                             ,data.frame(method = "glmnet", parameter = "lambda",
    #                                         vals = "9.342e-02")    
    #                                     )
            
            ret_lst <- myfit_mdl(mdl_specs_lst = myinit_mdl_specs_lst(mdl_specs_lst =
                list(
                id.prefix = paste0("Max.cor.Y.rcv.", rcv_n_folds, "X", rcv_n_repeats), 
                type = glb_model_type, 
    # tune.df = lcl_tune_models_df,            
                trainControl.method = "repeatedcv",
                trainControl.number = rcv_n_folds, 
                trainControl.repeats = rcv_n_repeats,
                trainControl.classProbs = glb_is_classification,
                trainControl.summaryFunction = glbMdlMetricSummaryFn,
                train.method = "glmnet", train.metric = glbMdlMetricSummary, 
                train.maximize = glbMdlMetricMaximize)),
                                indepVar = max_cor_y_x_vars, rsp_var = glb_rsp_var, 
                                fit_df = glbObsFit, OOB_df = glbObsOOB)
        }
    # Add parallel coordinates graph of glb_models_df[, glbMdlMetricsEval] to evaluate cv parameters
    tmp_models_cols <- c("id", "max.nTuningRuns",
                        glbMdlMetricsEval[glbMdlMetricsEval %in% names(glb_models_df)],
                        grep("opt.", names(glb_models_df), fixed = TRUE, value = TRUE)) 
    print(myplot_parcoord(obs_df = subset(glb_models_df, 
                                          grepl("Max.cor.Y.rcv.", id, fixed = TRUE), 
                                            select = -feats)[, tmp_models_cols],
                          id_var = "id"))
}
        
# Useful for stacking decisions
# fit.models_0_chunk_df <- myadd_chunk(fit.models_0_chunk_df, 
#                     paste0("fit.models_0_", "Max.cor.Y[rcv.1X1.cp.0|]"), major.inc = FALSE,
#                                     label.minor = "rpart")
# 
# ret_lst <- myfit_mdl(mdl_specs_lst = myinit_mdl_specs_lst(mdl_specs_lst = list(
#     id.prefix = "Max.cor.Y.rcv.1X1.cp.0", type = glb_model_type, trainControl.method = "none",
#     train.method = "rpart",
#     tune.df=data.frame(method="rpart", parameter="cp", min=0.0, max=0.0, by=0.1))),
#                     indepVar=max_cor_y_x_vars, rsp_var=glb_rsp_var, 
#                     fit_df=glbObsFit, OOB_df=glbObsOOB)

#stop(here"); glb2Sav(); all.equal(glb_models_df, sav_models_df)
# if (glb_is_regression || glb_is_binomial) # For multinomials this model will be run next by default
ret_lst <- myfit_mdl(mdl_specs_lst = myinit_mdl_specs_lst(mdl_specs_lst = list(
                        id.prefix = "Max.cor.Y", 
                        type = glb_model_type, trainControl.method = "repeatedcv",
                        trainControl.number = glb_rcv_n_folds, 
                        trainControl.repeats = glb_rcv_n_repeats,
                        trainControl.classProbs = glb_is_classification,
                        trainControl.summaryFunction = glbMdlMetricSummaryFn,
                        trainControl.allowParallel = glbMdlAllowParallel,                        
                        train.metric = glbMdlMetricSummary, 
                        train.maximize = glbMdlMetricMaximize,    
                        train.method = "rpart")),
                    indepVar = max_cor_y_x_vars, rsp_var = glb_rsp_var, 
                    fit_df = glbObsFit, OOB_df = glbObsOOB)
## [1] "myfit_mdl: enter: 0.001000 secs"
## [1] "myfit_mdl: fitting model: Max.cor.Y##rcv#rpart"
## [1] "    indepVar: Gender.fctr,Q101163.fctr"
## [1] "myfit_mdl: setup complete: 0.673000 secs"
## Loading required package: rpart
## Aggregating results
## Selecting tuning parameters
## Fitting cp = 0.00633 on full training set
## [1] "myfit_mdl: train complete: 2.143000 secs"
## Loading required package: rpart.plot

## Call:
## rpart(formula = .outcome ~ ., control = list(minsplit = 20, minbucket = 7, 
##     cp = 0, maxcompete = 4, maxsurrogate = 5, usesurrogate = 2, 
##     surrogatestyle = 0, maxdepth = 30, xval = 0))
##   n= 1746 
## 
##           CP nsplit rel error
## 1 0.02530864      0 1.0000000
## 2 0.00000000      2 0.9493827
## 
## Variable importance
##    Gender.fctrM    Gender.fctrF Q101163.fctrMom 
##              39              36              26 
## 
## Node number 1: 1746 observations,    complexity param=0.02530864
##   predicted class=D  expected loss=0.4639175  P(node) =1
##     class counts:   936   810
##    probabilities: 0.536 0.464 
##   left son=2 (738 obs) right son=3 (1008 obs)
##   Primary splits:
##       Gender.fctrM    < 0.5 to the left,  improve=8.4274760, (0 missing)
##       Q101163.fctrMom < 0.5 to the right, improve=7.4217640, (0 missing)
##       Gender.fctrF    < 0.5 to the right, improve=7.1271380, (0 missing)
##       Q101163.fctrDad < 0.5 to the left,  improve=0.7371618, (0 missing)
##   Surrogate splits:
##       Gender.fctrF < 0.5 to the right, agree=0.967, adj=0.921, (0 split)
## 
## Node number 2: 738 observations
##   predicted class=D  expected loss=0.4065041  P(node) =0.4226804
##     class counts:   438   300
##    probabilities: 0.593 0.407 
## 
## Node number 3: 1008 observations,    complexity param=0.02530864
##   predicted class=R  expected loss=0.4940476  P(node) =0.5773196
##     class counts:   498   510
##    probabilities: 0.494 0.506 
##   left son=6 (87 obs) right son=7 (921 obs)
##   Primary splits:
##       Q101163.fctrMom < 0.5 to the right, improve=5.674500, (0 missing)
##       Q101163.fctrDad < 0.5 to the left,  improve=1.045878, (0 missing)
## 
## Node number 6: 87 observations
##   predicted class=D  expected loss=0.3333333  P(node) =0.04982818
##     class counts:    58    29
##    probabilities: 0.667 0.333 
## 
## Node number 7: 921 observations
##   predicted class=R  expected loss=0.4777416  P(node) =0.5274914
##     class counts:   440   481
##    probabilities: 0.478 0.522 
## 
## n= 1746 
## 
## node), split, n, loss, yval, (yprob)
##       * denotes terminal node
## 
## 1) root 1746 810 D (0.5360825 0.4639175)  
##   2) Gender.fctrM< 0.5 738 300 D (0.5934959 0.4065041) *
##   3) Gender.fctrM>=0.5 1008 498 R (0.4940476 0.5059524)  
##     6) Q101163.fctrMom>=0.5 87  29 D (0.6666667 0.3333333) *
##     7) Q101163.fctrMom< 0.5 921 440 R (0.4777416 0.5222584) *
## [1] "myfit_mdl: train diagnostics complete: 2.943000 secs"

## [1] "mypredict_mdl: maxMetricDf:"
##    threshold   f.score  accuracy
## 10      0.45 0.5557481 0.5595647
## 11      0.50 0.5557481 0.5595647

##          Prediction
## Reference   D   R
##         D 496 440
##         R 329 481
##       Accuracy          Kappa  AccuracyLower  AccuracyUpper   AccuracyNull 
##   5.595647e-01   1.226108e-01   5.359087e-01   5.830202e-01   5.360825e-01 
## AccuracyPValue  McnemarPValue 
##   2.586206e-02   7.287418e-05

## [1] "mypredict_mdl: maxMetricDf:"
##    threshold   f.score  accuracy
## 10      0.45 0.5421412 0.5410959
## 11      0.50 0.5421412 0.5410959

##          Prediction
## Reference   D   R
##         D 118 117
##         R  84 119
##       Accuracy          Kappa  AccuracyLower  AccuracyUpper   AccuracyNull 
##     0.54109589     0.08736757     0.49314387     0.58848926     0.53652968 
## AccuracyPValue  McnemarPValue 
##     0.44331935     0.02400145 
## [1] "myfit_mdl: predict complete: 8.373000 secs"
##                     id                    feats max.nTuningRuns
## 1 Max.cor.Y##rcv#rpart Gender.fctr,Q101163.fctr               5
##   min.elapsedtime.everything min.elapsedtime.final max.AUCpROC.fit
## 1                      1.464                 0.011       0.5618708
##   max.Sens.fit max.Spec.fit max.AUCROCR.fit opt.prob.threshold.fit
## 1    0.5299145    0.5938272       0.5649691                    0.5
##   max.f.score.fit max.Accuracy.fit max.AccuracyLower.fit
## 1       0.5557481        0.5595647             0.5359087
##   max.AccuracyUpper.fit max.Kappa.fit max.AUCpROC.OOB max.Sens.OOB
## 1             0.5830202     0.1225971       0.5441673    0.5021277
##   max.Spec.OOB max.AUCROCR.OOB opt.prob.threshold.OOB max.f.score.OOB
## 1    0.5862069        0.544859                    0.5       0.5421412
##   max.Accuracy.OOB max.AccuracyLower.OOB max.AccuracyUpper.OOB
## 1        0.5410959             0.4931439             0.5884893
##   max.Kappa.OOB max.AccuracySD.fit max.KappaSD.fit
## 1    0.08736757         0.01648052      0.03319541
## [1] "myfit_mdl: exit: 8.432000 secs"
if ((length(glbFeatsDateTime) > 0) && 
    (sum(grepl(paste(names(glbFeatsDateTime), "\\.day\\.minutes\\.poly\\.", sep = ""),
               names(glbObsAll))) > 0)) {
    fit.models_0_chunk_df <- myadd_chunk(fit.models_0_chunk_df, 
                    paste0("fit.models_0_", "Max.cor.Y.Time.Poly"), major.inc = FALSE,
                                    label.minor = "glmnet")

    indepVars <- c(max_cor_y_x_vars, 
            grep(paste(names(glbFeatsDateTime), "\\.day\\.minutes\\.poly\\.", sep = ""),
                        names(glbObsAll), value = TRUE))
    indepVars <- myadjustInteractionFeats(glb_feats_df, indepVars)
    ret_lst <- myfit_mdl(mdl_specs_lst = myinit_mdl_specs_lst(mdl_specs_lst = list(
            id.prefix = "Max.cor.Y.Time.Poly", 
            type = glb_model_type, trainControl.method = "repeatedcv",
            trainControl.number = glb_rcv_n_folds, trainControl.repeats = glb_rcv_n_repeats,
            trainControl.classProbs = glb_is_classification,
            trainControl.summaryFunction = glbMdlMetricSummaryFn,
            trainControl.allowParallel = glbMdlAllowParallel,            
            train.metric = glbMdlMetricSummary, 
            train.maximize = glbMdlMetricMaximize,    
            train.method = "glmnet")),
        indepVar = indepVars,
        rsp_var = glb_rsp_var, 
        fit_df = glbObsFit, OOB_df = glbObsOOB)
}

if ((length(glbFeatsDateTime) > 0) && 
    (sum(grepl(paste(names(glbFeatsDateTime), "\\.last[[:digit:]]", sep = ""),
               names(glbObsAll))) > 0)) {
    fit.models_0_chunk_df <- myadd_chunk(fit.models_0_chunk_df, 
                    paste0("fit.models_0_", "Max.cor.Y.Time.Lag"), major.inc = FALSE,
                                    label.minor = "glmnet")

    indepVars <- c(max_cor_y_x_vars, 
            grep(paste(names(glbFeatsDateTime), "\\.last[[:digit:]]", sep = ""),
                        names(glbObsAll), value = TRUE))
    indepVars <- myadjustInteractionFeats(glb_feats_df, indepVars)
    ret_lst <- myfit_mdl(mdl_specs_lst = myinit_mdl_specs_lst(mdl_specs_lst = list(
        id.prefix = "Max.cor.Y.Time.Lag", 
        type = glb_model_type, 
        tune.df = glbMdlTuneParams,        
        trainControl.method = "repeatedcv",
        trainControl.number = glb_rcv_n_folds, trainControl.repeats = glb_rcv_n_repeats,
        trainControl.classProbs = glb_is_classification,
        trainControl.summaryFunction = glbMdlMetricSummaryFn,
        trainControl.allowParallel = glbMdlAllowParallel,        
        train.metric = glbMdlMetricSummary, 
        train.maximize = glbMdlMetricMaximize,    
        train.method = "glmnet")),
        indepVar = indepVars,
        rsp_var = glb_rsp_var, 
        fit_df = glbObsFit, OOB_df = glbObsOOB)
}

if (length(glbFeatsText) > 0) {
    fit.models_0_chunk_df <- myadd_chunk(fit.models_0_chunk_df, 
                    paste0("fit.models_0_", "Txt.*"), major.inc = FALSE,
                                    label.minor = "glmnet")

    indepVars <- c(max_cor_y_x_vars)
    for (txtFeat in names(glbFeatsText))
        indepVars <- union(indepVars, 
            grep(paste(str_to_upper(substr(txtFeat, 1, 1)), "\\.(?!([T|P]\\.))", sep = ""),
                        names(glbObsAll), perl = TRUE, value = TRUE))
    indepVars <- myadjustInteractionFeats(glb_feats_df, indepVars)
    ret_lst <- myfit_mdl(mdl_specs_lst = myinit_mdl_specs_lst(mdl_specs_lst = list(
        id.prefix = "Max.cor.Y.Text.nonTP", 
        type = glb_model_type, 
        tune.df = glbMdlTuneParams,        
        trainControl.method = "repeatedcv",
        trainControl.number = glb_rcv_n_folds, trainControl.repeats = glb_rcv_n_repeats,
        trainControl.classProbs = glb_is_classification,
        trainControl.summaryFunction = glbMdlMetricSummaryFn,
        trainControl.allowParallel = glbMdlAllowParallel,                                
        train.metric = glbMdlMetricSummary, 
        train.maximize = glbMdlMetricMaximize,    
        train.method = "glmnet")),
        indepVar = indepVars,
        rsp_var = glb_rsp_var, 
        fit_df = glbObsFit, OOB_df = glbObsOOB)

    indepVars <- c(max_cor_y_x_vars)
    for (txtFeat in names(glbFeatsText))
        indepVars <- union(indepVars, 
            grep(paste(str_to_upper(substr(txtFeat, 1, 1)), "\\.T\\.", sep = ""),
                        names(glbObsAll), perl = TRUE, value = TRUE))
    indepVars <- myadjustInteractionFeats(glb_feats_df, indepVars)
    ret_lst <- myfit_mdl(mdl_specs_lst = myinit_mdl_specs_lst(mdl_specs_lst = list(
        id.prefix = "Max.cor.Y.Text.onlyT", 
        type = glb_model_type, 
        tune.df = glbMdlTuneParams,        
        trainControl.method = "repeatedcv",
        trainControl.number = glb_rcv_n_folds, trainControl.repeats = glb_rcv_n_repeats,
        trainControl.classProbs = glb_is_classification,
        trainControl.summaryFunction = glbMdlMetricSummaryFn,
        train.metric = glbMdlMetricSummary, 
        train.maximize = glbMdlMetricMaximize,    
        train.method = "glmnet")),
        indepVar = indepVars,
        rsp_var = glb_rsp_var, 
        fit_df = glbObsFit, OOB_df = glbObsOOB)

    indepVars <- c(max_cor_y_x_vars)
    for (txtFeat in names(glbFeatsText))
        indepVars <- union(indepVars, 
            grep(paste(str_to_upper(substr(txtFeat, 1, 1)), "\\.P\\.", sep = ""),
                        names(glbObsAll), perl = TRUE, value = TRUE))
    indepVars <- myadjustInteractionFeats(glb_feats_df, indepVars)
    ret_lst <- myfit_mdl(mdl_specs_lst = myinit_mdl_specs_lst(mdl_specs_lst = list(
        id.prefix = "Max.cor.Y.Text.onlyP", 
        type = glb_model_type, 
        tune.df = glbMdlTuneParams,        
        trainControl.method = "repeatedcv",
        trainControl.number = glb_rcv_n_folds, trainControl.repeats = glb_rcv_n_repeats,
        trainControl.classProbs = glb_is_classification,
        trainControl.summaryFunction = glbMdlMetricSummaryFn,
        trainControl.allowParallel = glbMdlAllowParallel,        
        train.metric = glbMdlMetricSummary, 
        train.maximize = glbMdlMetricMaximize,    
        train.method = "glmnet")),
        indepVar = indepVars,
        rsp_var = glb_rsp_var, 
        fit_df = glbObsFit, OOB_df = glbObsOOB)
}

# Interactions.High.cor.Y
if (length(int_feats <- setdiff(setdiff(unique(glb_feats_df$cor.high.X), NA), 
                                subset(glb_feats_df, nzv)$id)) > 0) {
    fit.models_0_chunk_df <- myadd_chunk(fit.models_0_chunk_df, 
                    paste0("fit.models_0_", "Interact.High.cor.Y"), major.inc = FALSE,
                                    label.minor = "glmnet")

    ret_lst <- myfit_mdl(mdl_specs_lst=myinit_mdl_specs_lst(mdl_specs_lst=list(
        id.prefix="Interact.High.cor.Y", 
        type=glb_model_type, trainControl.method="repeatedcv",
        trainControl.number=glb_rcv_n_folds, trainControl.repeats=glb_rcv_n_repeats,
        trainControl.classProbs = glb_is_classification,
        trainControl.summaryFunction = glbMdlMetricSummaryFn,
        trainControl.allowParallel = glbMdlAllowParallel,
        train.metric = glbMdlMetricSummary, 
        train.maximize = glbMdlMetricMaximize,    
        train.method="glmnet")),
        indepVar=c(max_cor_y_x_vars, paste(max_cor_y_x_vars[1], int_feats, sep=":")),
        rsp_var=glb_rsp_var, 
        fit_df=glbObsFit, OOB_df=glbObsOOB)
}    
##                              label step_major step_minor label_minor
## 4   fit.models_0_Max.cor.Y.rcv.*X*          1          3      glmnet
## 5 fit.models_0_Interact.High.cor.Y          1          4      glmnet
##       bgn     end elapsed
## 4 305.568 320.895  15.327
## 5 320.896      NA      NA
## [1] "myfit_mdl: enter: 0.000000 secs"
## [1] "myfit_mdl: fitting model: Interact.High.cor.Y##rcv#glmnet"
## [1] "    indepVar: Gender.fctr,Q101163.fctr,Gender.fctr:Q100562.fctr,Gender.fctr:Q102674.fctr,Gender.fctr:Q100689.fctr,Gender.fctr:Q113583.fctr,Gender.fctr:Q98078.fctr"
## [1] "myfit_mdl: setup complete: 0.693000 secs"
## Aggregating results
## Selecting tuning parameters
## Fitting alpha = 0.325, lambda = 0.0212 on full training set
## [1] "myfit_mdl: train complete: 3.195000 secs"
## Warning in myfit_mdl(mdl_specs_lst = myinit_mdl_specs_lst(mdl_specs_lst
## = list(id.prefix = "Interact.High.cor.Y", : model's bestTune found at an
## extreme of tuneGrid for parameter: lambda

##             Length Class      Mode     
## a0            61   -none-     numeric  
## beta        2074   dgCMatrix  S4       
## df            61   -none-     numeric  
## dim            2   -none-     numeric  
## lambda        61   -none-     numeric  
## dev.ratio     61   -none-     numeric  
## nulldev        1   -none-     numeric  
## npasses        1   -none-     numeric  
## jerr           1   -none-     numeric  
## offset         1   -none-     logical  
## classnames     2   -none-     character
## call           5   -none-     call     
## nobs           1   -none-     numeric  
## lambdaOpt      1   -none-     numeric  
## xNames        34   -none-     character
## problemType    1   -none-     character
## tuneValue      2   data.frame list     
## obsLevels      2   -none-     character
## [1] "min lambda > lambdaOpt:"
##                    (Intercept)                   Gender.fctrF 
##                    -0.23569103                    -0.02463720 
##                   Gender.fctrM                Q101163.fctrDad 
##                     0.28604244                     0.09092952 
##                Q101163.fctrMom    Gender.fctrF:Q100562.fctrNo 
##                    -0.46658238                     0.19467105 
##    Gender.fctrM:Q100562.fctrNo    Gender.fctrN:Q100689.fctrNo 
##                     0.33808832                    -0.17645536 
##   Gender.fctrM:Q100689.fctrYes    Gender.fctrM:Q102674.fctrNo 
##                    -0.23431799                     0.14229138 
##   Gender.fctrF:Q102674.fctrYes  Gender.fctrM:Q113583.fctrTalk 
##                    -0.33309117                     0.09379886 
## Gender.fctrF:Q113583.fctrTunes Gender.fctrM:Q113583.fctrTunes 
##                    -0.02602276                    -0.24551432 
##     Gender.fctrN:Q98078.fctrNo     Gender.fctrM:Q98078.fctrNo 
##                    -0.60124013                    -0.06487166 
##    Gender.fctrN:Q98078.fctrYes    Gender.fctrF:Q98078.fctrYes 
##                     0.36450799                    -0.16051393 
## [1] "max lambda < lambdaOpt:"
##                    (Intercept)                   Gender.fctrF 
##                    -0.23955407                    -0.02251079 
##                   Gender.fctrM                Q101163.fctrDad 
##                     0.29480400                     0.10349126 
##                Q101163.fctrMom    Gender.fctrF:Q100562.fctrNo 
##                    -0.47271466                     0.21871570 
##    Gender.fctrM:Q100562.fctrNo    Gender.fctrN:Q100689.fctrNo 
##                     0.35552549                    -0.28822233 
##   Gender.fctrM:Q100689.fctrYes    Gender.fctrM:Q102674.fctrNo 
##                    -0.25473783                     0.15325516 
##   Gender.fctrF:Q102674.fctrYes  Gender.fctrM:Q113583.fctrTalk 
##                    -0.35093199                     0.09868848 
## Gender.fctrF:Q113583.fctrTunes Gender.fctrM:Q113583.fctrTunes 
##                    -0.03103399                    -0.25930572 
##     Gender.fctrN:Q98078.fctrNo     Gender.fctrM:Q98078.fctrNo 
##                    -0.65309190                    -0.07788385 
##    Gender.fctrN:Q98078.fctrYes    Gender.fctrF:Q98078.fctrYes 
##                     0.42921693                    -0.17363486 
## [1] "myfit_mdl: train diagnostics complete: 3.827000 secs"

##          Prediction
## Reference   D   R
##         D 614 322
##         R 407 403
##       Accuracy          Kappa  AccuracyLower  AccuracyUpper   AccuracyNull 
##   5.824742e-01   1.546058e-01   5.589337e-01   6.057371e-01   5.360825e-01 
## AccuracyPValue  McnemarPValue 
##   5.357338e-05   1.863848e-03

##          Prediction
## Reference   D   R
##         D 152  83
##         R 107  96
##       Accuracy          Kappa  AccuracyLower  AccuracyUpper   AccuracyNull 
##      0.5662100      0.1206864      0.5183397      0.6131802      0.5365297 
## AccuracyPValue  McnemarPValue 
##      0.1153889      0.0951976 
## [1] "myfit_mdl: predict complete: 9.390000 secs"
##                                id
## 1 Interact.High.cor.Y##rcv#glmnet
##                                                                                                                                                  feats
## 1 Gender.fctr,Q101163.fctr,Gender.fctr:Q100562.fctr,Gender.fctr:Q102674.fctr,Gender.fctr:Q100689.fctr,Gender.fctr:Q113583.fctr,Gender.fctr:Q98078.fctr
##   max.nTuningRuns min.elapsedtime.everything min.elapsedtime.final
## 1              25                      2.492                 0.099
##   max.AUCpROC.fit max.Sens.fit max.Spec.fit max.AUCROCR.fit
## 1       0.5767569    0.6559829    0.4975309       0.6023801
##   opt.prob.threshold.fit max.f.score.fit max.Accuracy.fit
## 1                    0.5       0.5250814        0.5578465
##   max.AccuracyLower.fit max.AccuracyUpper.fit max.Kappa.fit
## 1             0.5589337             0.6057371     0.1056567
##   max.AUCpROC.OOB max.Sens.OOB max.Spec.OOB max.AUCROCR.OOB
## 1       0.5598575    0.6468085    0.4729064       0.5851273
##   opt.prob.threshold.OOB max.f.score.OOB max.Accuracy.OOB
## 1                    0.5       0.5026178          0.56621
##   max.AccuracyLower.OOB max.AccuracyUpper.OOB max.Kappa.OOB
## 1             0.5183397             0.6131802     0.1206864
##   max.AccuracySD.fit max.KappaSD.fit
## 1         0.02368393      0.04801874
## [1] "myfit_mdl: exit: 9.470000 secs"
# Low.cor.X
fit.models_0_chunk_df <- myadd_chunk(fit.models_0_chunk_df, 
                        paste0("fit.models_0_", "Low.cor.X"), major.inc = FALSE,
                                     label.minor = "glmnet")
##                              label step_major step_minor label_minor
## 5 fit.models_0_Interact.High.cor.Y          1          4      glmnet
## 6           fit.models_0_Low.cor.X          1          5      glmnet
##       bgn     end elapsed
## 5 320.896 330.381   9.485
## 6 330.381      NA      NA
indepVar <- mygetIndepVar(glb_feats_df)
indepVar <- setdiff(indepVar, unique(glb_feats_df$cor.high.X))
ret_lst <- myfit_mdl(mdl_specs_lst = myinit_mdl_specs_lst(mdl_specs_lst = list(
            id.prefix = "Low.cor.X", 
            type = glb_model_type, 
            tune.df = glbMdlTuneParams,        
            trainControl.method = "repeatedcv",
            trainControl.number = glb_rcv_n_folds, trainControl.repeats = glb_rcv_n_repeats,
            trainControl.classProbs = glb_is_classification,
            trainControl.summaryFunction = glbMdlMetricSummaryFn,
            trainControl.allowParallel = glbMdlAllowParallel,
            train.metric = glbMdlMetricSummary, 
            train.maximize = glbMdlMetricMaximize,    
            train.method = "glmnet")),
        indepVar = indepVar, rsp_var = glb_rsp_var, 
        fit_df = glbObsFit, OOB_df = glbObsOOB)
## [1] "myfit_mdl: enter: 0.000000 secs"
## [1] "myfit_mdl: fitting model: Low.cor.X##rcv#glmnet"
## [1] "    indepVar: Gender.fctr,Q113181.fctr,Q120472.fctr,Q115611.fctr,Q120650.fctr,Q118237.fctr,.rnorm,Q122120.fctr,Q110740.fctr,Q122770.fctr,Q118117.fctr,Income.fctr,Q116441.fctr,Q118233.fctr,Q106272.fctr,Q119650.fctr,Q124742.fctr,Q122771.fctr,Q99480.fctr,Q116197.fctr,Q116881.fctr,Q101596.fctr,Q122769.fctr,Q108855.fctr,Q120014.fctr,Q119334.fctr,Q106993.fctr,Q107869.fctr,Q121011.fctr,Q117186.fctr,Q106997.fctr,Q108617.fctr,Q98197.fctr,Q106042.fctr,Q115777.fctr,Q123621.fctr,Q106388.fctr,Q114152.fctr,Q124122.fctr,Q120194.fctr,Q116797.fctr,Q105655.fctr,Q115899.fctr,Q116448.fctr,Q117193.fctr,Q108754.fctr,Q108856.fctr,YOB.Age.fctr,Q123464.fctr,Q99581.fctr,Q114961.fctr,Q104996.fctr,Q108343.fctr,Q120012.fctr,Q120978.fctr,Q98578.fctr,Q103293.fctr,Q106389.fctr,Q98869.fctr,Q112512.fctr,Q116953.fctr,Q100010.fctr,Q111220.fctr,Q102906.fctr,Q121700.fctr,Q112478.fctr,Q115610.fctr,Q119851.fctr,Q114517.fctr,Q118892.fctr,Q115602.fctr,Q120379.fctr,Q107491.fctr,Q114748.fctr,Q99982.fctr,Q113992.fctr,Q115390.fctr,Q118232.fctr,Q96024.fctr,Q115195.fctr,Q121699.fctr,Q100680.fctr,Q111580.fctr,Q102289.fctr,Q102687.fctr,Q105840.fctr,Q101162.fctr,Q108950.fctr,Q116601.fctr,Q108342.fctr,Q113584.fctr,Q109367.fctr,Q99716.fctr,Hhold.fctr,Q112270.fctr,Q98059.fctr,Q111848.fctr,Q114386.fctr,Q102089.fctr,Edn.fctr,Q101163.fctr,YOB.Age.fctr:YOB.Age.dff,Q109244.fctr:.clusterid.fctr"
## [1] "myfit_mdl: setup complete: 0.687000 secs"
## Aggregating results
## Selecting tuning parameters
## Fitting alpha = 0.775, lambda = 0.0247 on full training set
## [1] "myfit_mdl: train complete: 7.359000 secs"
## Warning in myfit_mdl(mdl_specs_lst = myinit_mdl_specs_lst(mdl_specs_lst
## = list(id.prefix = "Low.cor.X", : model's bestTune found at an extreme of
## tuneGrid for parameter: lambda

##             Length Class      Mode     
## a0             66  -none-     numeric  
## beta        15906  dgCMatrix  S4       
## df             66  -none-     numeric  
## dim             2  -none-     numeric  
## lambda         66  -none-     numeric  
## dev.ratio      66  -none-     numeric  
## nulldev         1  -none-     numeric  
## npasses         1  -none-     numeric  
## jerr            1  -none-     numeric  
## offset          1  -none-     logical  
## classnames      2  -none-     character
## call            5  -none-     call     
## nobs            1  -none-     numeric  
## lambdaOpt       1  -none-     numeric  
## xNames        241  -none-     character
## problemType     1  -none-     character
## tuneValue       2  data.frame list     
## obsLevels       2  -none-     character
## [1] "min lambda > lambdaOpt:"
##               (Intercept)                Edn.fctr.L 
##               -0.23846652               -0.03304072 
##                Edn.fctr^4              Gender.fctrM 
##                0.05128366                0.21492884 
##             Hhold.fctrPKy           Q101163.fctrMom 
##                0.27426485               -0.31022847 
##            Q104996.fctrNo            Q106389.fctrNo 
##                0.01753369                0.13654651 
## Q108950.fctrRisk-friendly            Q113181.fctrNo 
##               -0.08072459               -0.07404136 
##           Q113181.fctrYes            Q115195.fctrNo 
##                0.19290110                0.01918436 
##            Q115611.fctrNo           Q115611.fctrYes 
##               -0.18111495                0.27929364 
##            Q116441.fctrNo           Q116441.fctrYes 
##               -0.04718884                0.11374224 
##            Q116601.fctrNo            Q119851.fctrNo 
##                0.29924654                0.03449318 
##           Q120379.fctrYes            Q120650.fctrNo 
##               -0.06195411               -0.10688317 
##             Q98197.fctrNo            Q98197.fctrYes 
##               -0.32696152                0.06474982 
##             Q98869.fctrNo            Q99480.fctrYes 
##               -0.12408063                0.04903837 
## [1] "max lambda < lambdaOpt:"
##               (Intercept)                Edn.fctr.L 
##             -0.2486882957             -0.0490062685 
##                Edn.fctr^4              Gender.fctrM 
##              0.0638720221              0.2296986941 
##             Hhold.fctrPKy           Q101163.fctrMom 
##              0.3425353890             -0.3424319842 
##            Q104996.fctrNo            Q106388.fctrNo 
##              0.0437966880              0.0050973617 
##            Q106389.fctrNo Q108950.fctrRisk-friendly 
##              0.1559905300             -0.1207488929 
##            Q113181.fctrNo           Q113181.fctrYes 
##             -0.0859745166              0.2039395179 
##           Q114386.fctrTMI            Q115195.fctrNo 
##             -0.0195365274              0.0416692306 
##            Q115611.fctrNo           Q115611.fctrYes 
##             -0.1904803883              0.2883793596 
##            Q116441.fctrNo           Q116441.fctrYes 
##             -0.0699604558              0.1219971884 
##            Q116601.fctrNo           Q118892.fctrYes 
##              0.3360681100             -0.0055063248 
##            Q119851.fctrNo           Q119851.fctrYes 
##              0.0525925546             -0.0006243739 
##           Q120379.fctrYes       Q120472.fctrScience 
##             -0.0780770859              0.0033689973 
##            Q120650.fctrNo            Q122771.fctrPt 
##             -0.1378760071              0.0255145580 
##             Q98197.fctrNo            Q98197.fctrYes 
##             -0.3504038475              0.0683594644 
##             Q98869.fctrNo            Q99480.fctrYes 
##             -0.1515925410              0.0729293498 
## [1] "myfit_mdl: train diagnostics complete: 8.022000 secs"

##          Prediction
## Reference   D   R
##         D 509 427
##         R 251 559
##       Accuracy          Kappa  AccuracyLower  AccuracyUpper   AccuracyNull 
##   6.116838e-01   2.305550e-01   5.883650e-01   6.346266e-01   5.360825e-01 
## AccuracyPValue  McnemarPValue 
##   1.110403e-10   1.806867e-11

##          Prediction
## Reference   D   R
##         D 182  53
##         R 134  69
##       Accuracy          Kappa  AccuracyLower  AccuracyUpper   AccuracyNull 
##   5.730594e-01   1.175634e-01   5.252321e-01   6.198932e-01   5.365297e-01 
## AccuracyPValue  McnemarPValue 
##   6.851176e-02   4.910431e-09 
## [1] "myfit_mdl: predict complete: 16.646000 secs"
##                      id
## 1 Low.cor.X##rcv#glmnet
##                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             feats
## 1 Gender.fctr,Q113181.fctr,Q120472.fctr,Q115611.fctr,Q120650.fctr,Q118237.fctr,.rnorm,Q122120.fctr,Q110740.fctr,Q122770.fctr,Q118117.fctr,Income.fctr,Q116441.fctr,Q118233.fctr,Q106272.fctr,Q119650.fctr,Q124742.fctr,Q122771.fctr,Q99480.fctr,Q116197.fctr,Q116881.fctr,Q101596.fctr,Q122769.fctr,Q108855.fctr,Q120014.fctr,Q119334.fctr,Q106993.fctr,Q107869.fctr,Q121011.fctr,Q117186.fctr,Q106997.fctr,Q108617.fctr,Q98197.fctr,Q106042.fctr,Q115777.fctr,Q123621.fctr,Q106388.fctr,Q114152.fctr,Q124122.fctr,Q120194.fctr,Q116797.fctr,Q105655.fctr,Q115899.fctr,Q116448.fctr,Q117193.fctr,Q108754.fctr,Q108856.fctr,YOB.Age.fctr,Q123464.fctr,Q99581.fctr,Q114961.fctr,Q104996.fctr,Q108343.fctr,Q120012.fctr,Q120978.fctr,Q98578.fctr,Q103293.fctr,Q106389.fctr,Q98869.fctr,Q112512.fctr,Q116953.fctr,Q100010.fctr,Q111220.fctr,Q102906.fctr,Q121700.fctr,Q112478.fctr,Q115610.fctr,Q119851.fctr,Q114517.fctr,Q118892.fctr,Q115602.fctr,Q120379.fctr,Q107491.fctr,Q114748.fctr,Q99982.fctr,Q113992.fctr,Q115390.fctr,Q118232.fctr,Q96024.fctr,Q115195.fctr,Q121699.fctr,Q100680.fctr,Q111580.fctr,Q102289.fctr,Q102687.fctr,Q105840.fctr,Q101162.fctr,Q108950.fctr,Q116601.fctr,Q108342.fctr,Q113584.fctr,Q109367.fctr,Q99716.fctr,Hhold.fctr,Q112270.fctr,Q98059.fctr,Q111848.fctr,Q114386.fctr,Q102089.fctr,Edn.fctr,Q101163.fctr,YOB.Age.fctr:YOB.Age.dff,Q109244.fctr:.clusterid.fctr
##   max.nTuningRuns min.elapsedtime.everything min.elapsedtime.final
## 1              25                      6.595                 0.596
##   max.AUCpROC.fit max.Sens.fit max.Spec.fit max.AUCROCR.fit
## 1       0.5945869    0.8076923    0.3814815       0.6635631
##   opt.prob.threshold.fit max.f.score.fit max.Accuracy.fit
## 1                   0.45       0.6224944        0.5631921
##   max.AccuracyLower.fit max.AccuracyUpper.fit max.Kappa.fit
## 1              0.588365             0.6346266     0.1014582
##   max.AUCpROC.OOB max.Sens.OOB max.Spec.OOB max.AUCROCR.OOB
## 1       0.5571848    0.7744681    0.3399015       0.6077246
##   opt.prob.threshold.OOB max.f.score.OOB max.Accuracy.OOB
## 1                    0.5       0.4246154        0.5730594
##   max.AccuracyLower.OOB max.AccuracyUpper.OOB max.Kappa.OOB
## 1             0.5252321             0.6198932     0.1175634
##   max.AccuracySD.fit max.KappaSD.fit
## 1          0.0182199      0.03682851
## [1] "myfit_mdl: exit: 16.908000 secs"
fit.models_0_chunk_df <- 
    myadd_chunk(fit.models_0_chunk_df, "fit.models_0_end", major.inc = FALSE,
                label.minor = "teardown")
##                    label step_major step_minor label_minor     bgn     end
## 6 fit.models_0_Low.cor.X          1          5      glmnet 330.381 347.326
## 7       fit.models_0_end          1          6    teardown 347.326      NA
##   elapsed
## 6  16.945
## 7      NA
rm(ret_lst)

glb_chunks_df <- myadd_chunk(glb_chunks_df, "fit.models", major.inc = FALSE)
##         label step_major step_minor label_minor     bgn     end elapsed
## 16 fit.models          8          0           0 291.196 347.339  56.143
## 17 fit.models          8          1           1 347.340      NA      NA

```{r fit.models_1, cache=FALSE, fig.height=10, fig.width=15, eval=myevlChunk(glbChunks, glbOut$pfx)}

##              label step_major step_minor label_minor    bgn end elapsed
## 1 fit.models_1_bgn          1          0       setup 352.06  NA      NA
##                label step_major step_minor label_minor     bgn     end
## 1   fit.models_1_bgn          1          0       setup 352.060 352.073
## 2 fit.models_1_All.X          1          1       setup 352.073      NA
##   elapsed
## 1   0.013
## 2      NA
##                label step_major step_minor label_minor     bgn     end
## 2 fit.models_1_All.X          1          1       setup 352.073 352.081
## 3 fit.models_1_All.X          1          2      glmnet 352.081      NA
##   elapsed
## 2   0.008
## 3      NA
## [1] "myfit_mdl: enter: 0.001000 secs"
## [1] "myfit_mdl: fitting model: All.X##rcv#glmnet"
## [1] "    indepVar: Gender.fctr,Q113181.fctr,Q120472.fctr,Q115611.fctr,Q120650.fctr,Q118237.fctr,.rnorm,Q122120.fctr,Q110740.fctr,Q122770.fctr,Q118117.fctr,Income.fctr,Q116441.fctr,Q118233.fctr,Q106272.fctr,Q119650.fctr,Q124742.fctr,Q122771.fctr,Q99480.fctr,Q116197.fctr,Q116881.fctr,Q101596.fctr,Q122769.fctr,Q108855.fctr,Q120014.fctr,Q119334.fctr,Q106993.fctr,Q107869.fctr,Q121011.fctr,Q117186.fctr,Q106997.fctr,Q108617.fctr,Q98197.fctr,Q106042.fctr,Q115777.fctr,Q123621.fctr,Q106388.fctr,Q114152.fctr,Q124122.fctr,Q120194.fctr,Q116797.fctr,Q105655.fctr,Q115899.fctr,Q116448.fctr,Q117193.fctr,Q108754.fctr,Q108856.fctr,YOB.Age.fctr,Q123464.fctr,Q99581.fctr,Q114961.fctr,Q104996.fctr,Q108343.fctr,Q120012.fctr,Q120978.fctr,Q98578.fctr,Q103293.fctr,Q106389.fctr,Q98869.fctr,Q112512.fctr,Q116953.fctr,Q100010.fctr,Q111220.fctr,Q102906.fctr,Q121700.fctr,Q112478.fctr,Q115610.fctr,Q119851.fctr,Q114517.fctr,Q118892.fctr,Q115602.fctr,Q120379.fctr,Q107491.fctr,Q114748.fctr,Q99982.fctr,Q113992.fctr,Q115390.fctr,Q118232.fctr,Q96024.fctr,Q115195.fctr,Q121699.fctr,Q100680.fctr,Q111580.fctr,Q102289.fctr,Q102687.fctr,Q105840.fctr,Q101162.fctr,Q108950.fctr,Q116601.fctr,Q108342.fctr,Q100562.fctr,Q113584.fctr,Q109367.fctr,Q99716.fctr,Hhold.fctr,Q112270.fctr,Q98059.fctr,Q111848.fctr,Q102674.fctr,Q114386.fctr,Q98078.fctr,Q102089.fctr,Edn.fctr,Q100689.fctr,Q113583.fctr,Q101163.fctr,YOB.Age.fctr:YOB.Age.dff,Q109244.fctr:.clusterid.fctr"
## [1] "myfit_mdl: setup complete: 0.670000 secs"
## Aggregating results
## Selecting tuning parameters
## Fitting alpha = 0.1, lambda = 0.0247 on full training set
## [1] "myfit_mdl: train complete: 8.052000 secs"
## Warning in myfit_mdl(mdl_specs_lst = myinit_mdl_specs_lst(mdl_specs_lst
## = list(id.prefix = mdl_id_pfx, : model's bestTune found at an extreme of
## tuneGrid for parameter: alpha
## Warning in myfit_mdl(mdl_specs_lst = myinit_mdl_specs_lst(mdl_specs_lst
## = list(id.prefix = mdl_id_pfx, : model's bestTune found at an extreme of
## tuneGrid for parameter: lambda

##             Length Class      Mode     
## a0             74  -none-     numeric  
## beta        18574  dgCMatrix  S4       
## df             74  -none-     numeric  
## dim             2  -none-     numeric  
## lambda         74  -none-     numeric  
## dev.ratio      74  -none-     numeric  
## nulldev         1  -none-     numeric  
## npasses         1  -none-     numeric  
## jerr            1  -none-     numeric  
## offset          1  -none-     logical  
## classnames      2  -none-     character
## call            5  -none-     call     
## nobs            1  -none-     numeric  
## lambdaOpt       1  -none-     numeric  
## xNames        251  -none-     character
## problemType     1  -none-     character
## tuneValue       2  data.frame list     
## obsLevels       2  -none-     character
## [1] "min lambda > lambdaOpt:"
##                     (Intercept)                          .rnorm 
##                   -0.2024436525                    0.0111851436 
##                      Edn.fctr.L                      Edn.fctr.Q 
##                   -0.0442974895                    0.1947341846 
##                      Edn.fctr.C                      Edn.fctr^4 
##                    0.0570175265                    0.2729610307 
##                      Edn.fctr^5                      Edn.fctr^6 
##                    0.1346178755                   -0.1145427380 
##                      Edn.fctr^7                    Gender.fctrF 
##                   -0.1078588137                   -0.0594976461 
##                    Gender.fctrM                   Hhold.fctrMKn 
##                    0.2541399629                   -0.0301668970 
##                   Hhold.fctrMKy                   Hhold.fctrPKn 
##                    0.1228855404                   -0.1263731668 
##                   Hhold.fctrPKy                   Hhold.fctrSKn 
##                    0.8227048855                   -0.1017133418 
##                   Income.fctr.Q                   Income.fctr.C 
##                   -0.0368056668                    0.2164636280 
##                   Income.fctr^4                   Income.fctr^6 
##                    0.1609350877                    0.0977268563 
##                  Q100010.fctrNo                  Q100562.fctrNo 
##                   -0.2394966354                    0.4606105816 
##                  Q100680.fctrNo                  Q100689.fctrNo 
##                   -0.1709471157                   -0.0513563381 
##                 Q100689.fctrYes            Q101162.fctrOptimist 
##                   -0.4103754929                   -0.1197022400 
##           Q101162.fctrPessimist                 Q101163.fctrDad 
##                    0.2479866955                    0.1128744600 
##                 Q101163.fctrMom                  Q101596.fctrNo 
##                   -0.4836306838                    0.0924245633 
##                 Q101596.fctrYes                 Q102089.fctrOwn 
##                    0.3891077764                   -0.1970036403 
##                Q102089.fctrRent                 Q102289.fctrYes 
##                   -0.2712788062                   -0.1376479461 
##                  Q102674.fctrNo                 Q102674.fctrYes 
##                    0.1525589894                   -0.3468990160 
##                  Q102687.fctrNo                 Q102687.fctrYes 
##                    0.0452190915                   -0.0752103492 
##                 Q102906.fctrYes                  Q103293.fctrNo 
##                    0.0412085832                    0.0706766536 
##                  Q104996.fctrNo                 Q104996.fctrYes 
##                    0.2139199390                   -0.0703703021 
##                  Q105840.fctrNo                  Q106042.fctrNo 
##                    0.0565600386                    0.1116920002 
##                 Q106042.fctrYes                  Q106272.fctrNo 
##                    0.0435874318                    0.1311109254 
##                 Q106272.fctrYes                  Q106388.fctrNo 
##                    0.0931633962                    0.2348810419 
##                 Q106388.fctrYes                  Q106389.fctrNo 
##                   -0.1555239827                    0.2506641297 
##                 Q106389.fctrYes                  Q106993.fctrNo 
##                   -0.2124741176                    0.0984012281 
##                  Q106997.fctrGr                  Q107491.fctrNo 
##                   -0.0191634978                    0.1270529594 
##                 Q107491.fctrYes                 Q107869.fctrYes 
##                   -0.1996119277                    0.0438806922 
##           Q108342.fctrIn-person              Q108342.fctrOnline 
##                   -0.0754977713                   -0.2120492282 
##                 Q108343.fctrYes                  Q108617.fctrNo 
##                   -0.0408147050                    0.1972716556 
##              Q108855.fctrUmm...           Q108856.fctrSocialize 
##                    0.2459122687                    0.3563008371 
##               Q108856.fctrSpace            Q108950.fctrCautious 
##                   -0.0851883209                    0.0184484231 
##       Q108950.fctrRisk-friendly                  Q109367.fctrNo 
##                   -0.4519724545                   -0.2446126162 
##                 Q109367.fctrYes                 Q110740.fctrMac 
##                   -0.1397985033                    0.1611789305 
##                  Q110740.fctrPC          Q111580.fctrSupportive 
##                    0.2407760027                   -0.0241735616 
##                  Q111848.fctrNo                 Q111848.fctrYes 
##                   -0.1607959512                   -0.0628321292 
##                  Q112270.fctrNo                 Q112270.fctrYes 
##                   -0.0754607028                   -0.2790605626 
##                  Q112478.fctrNo                  Q112512.fctrNo 
##                    0.3082548243                    0.1892691776 
##                 Q112512.fctrYes                  Q113181.fctrNo 
##                    0.0029687606                   -0.0846028278 
##                 Q113181.fctrYes               Q113583.fctrTunes 
##                    0.4419331612                   -0.3278277496 
##              Q113584.fctrPeople                  Q113992.fctrNo 
##                   -0.0525650826                    0.0016350373 
##                 Q113992.fctrYes                 Q114152.fctrYes 
##                   -0.0451076804                   -0.0184985110 
##          Q114386.fctrMysterious                 Q114386.fctrTMI 
##                    0.1576222540                   -0.1005252524 
##                  Q114517.fctrNo                  Q114748.fctrNo 
##                   -0.0877373081                   -0.0324232246 
##                  Q114961.fctrNo                 Q114961.fctrYes 
##                   -0.0457356207                    0.1315039221 
##                  Q115195.fctrNo                 Q115195.fctrYes 
##                    0.1545806451                   -0.1992718748 
##                  Q115390.fctrNo                  Q115602.fctrNo 
##                    0.2923707845                   -0.0580081240 
##                  Q115610.fctrNo                 Q115610.fctrYes 
##                   -0.1781874528                    0.0085526779 
##                  Q115611.fctrNo                 Q115611.fctrYes 
##                   -0.2178168507                    0.4489561144 
##                 Q115777.fctrEnd               Q115777.fctrStart 
##                   -0.1582238319                    0.0954546193 
##                  Q115899.fctrCs                  Q115899.fctrMe 
##                   -0.2413296674                    0.0524273779 
##                Q116197.fctrP.M.                  Q116441.fctrNo 
##                    0.1743847518                   -0.2579497589 
##                 Q116441.fctrYes                  Q116448.fctrNo 
##                    0.2741072149                    0.1370455971 
##                 Q116448.fctrYes                  Q116601.fctrNo 
##                    0.0186617261                    0.4033024656 
##                 Q116601.fctrYes                  Q116797.fctrNo 
##                   -0.1515105731                    0.1935195280 
##                 Q116797.fctrYes               Q116881.fctrRight 
##                    0.0880484135                    0.0926906341 
##                  Q116953.fctrNo                 Q116953.fctrYes 
##                   -0.0840155376                   -0.1234424053 
##         Q117186.fctrCool headed          Q117186.fctrHot headed 
##                   -0.1482911575                    0.0942153297 
##           Q117193.fctrOdd hours      Q117193.fctrStandard hours 
##                    0.0002571871                    0.0132123662 
##                 Q118117.fctrYes                  Q118232.fctrId 
##                    0.1360914380                   -0.0983902752 
##                  Q118232.fctrPr                  Q118233.fctrNo 
##                   -0.1858983740                    0.0770490508 
##                  Q118237.fctrNo                  Q118892.fctrNo 
##                    0.0227463223                    0.0269276019 
##                 Q118892.fctrYes                  Q119334.fctrNo 
##                   -0.1352810482                   -0.0443721479 
##                 Q119334.fctrYes              Q119650.fctrGiving 
##                    0.0675175606                    0.0577118743 
##           Q119650.fctrReceiving                  Q119851.fctrNo 
##                    0.0588557694                    0.1693567303 
##                 Q119851.fctrYes                  Q120012.fctrNo 
##                   -0.0635863527                    0.1094341843 
##                  Q120014.fctrNo                 Q120014.fctrYes 
##                   -0.1455800740                   -0.0369657862 
##         Q120194.fctrStudy first                  Q120379.fctrNo 
##                   -0.2048195755                    0.0934504026 
##                 Q120379.fctrYes             Q120472.fctrScience 
##                   -0.2783381906                    0.1502910561 
##                  Q120650.fctrNo                 Q120650.fctrYes 
##                   -0.3740818549                    0.1219197129 
##                 Q120978.fctrYes                  Q121011.fctrNo 
##                   -0.1257172960                    0.1155251469 
##                  Q121699.fctrNo                 Q121699.fctrYes 
##                   -0.0664059892                   -0.1176807904 
##                  Q121700.fctrNo                 Q121700.fctrYes 
##                   -0.0074204904                   -0.1297393825 
##                 Q122120.fctrYes                  Q122770.fctrNo 
##                    0.2024255717                   -0.0592128862 
##                  Q122771.fctrPc                  Q122771.fctrPt 
##                   -0.0236138603                    0.3154235248 
##                 Q123464.fctrYes                  Q123621.fctrNo 
##                   -0.4770201306                    0.1091989131 
##                  Q124122.fctrNo                 Q124122.fctrYes 
##                    0.0653857387                   -0.0175577325 
##                 Q124742.fctrYes                   Q96024.fctrNo 
##                    0.0676186221                   -0.0380344967 
##                  Q96024.fctrYes           Q98059.fctrOnly-child 
##                    0.0838135457                    0.3365998906 
##                  Q98059.fctrYes                   Q98078.fctrNo 
##                   -0.0523795180                   -0.0208181384 
##                   Q98197.fctrNo                  Q98197.fctrYes 
##                   -0.5338590470                    0.2015399920 
##                   Q98578.fctrNo                  Q98578.fctrYes 
##                    0.1537791359                    0.1724820483 
##                   Q98869.fctrNo                   Q99480.fctrNo 
##                   -0.4069262486                   -0.1623722608 
##                  Q99480.fctrYes                  Q99581.fctrYes 
##                    0.3669223177                    0.0568685628 
##                   Q99716.fctrNo               Q99982.fctrCheck! 
##                   -0.1821926834                    0.0762862969 
##                  YOB.Age.fctr.L                  YOB.Age.fctr.Q 
##                   -0.3071663891                   -0.2647232726 
##                  YOB.Age.fctr.C                  YOB.Age.fctr^4 
##                   -0.1072842886                   -0.0524644398 
##                  YOB.Age.fctr^5                  YOB.Age.fctr^7 
##                   -0.0269230656                    0.1194405569 
##                  YOB.Age.fctr^8 Q109244.fctrNA:.clusterid.fctr2 
##                    0.0857630594                   -0.0111457076 
## Q109244.fctrNA:.clusterid.fctr3 YOB.Age.fctr(15,20]:YOB.Age.dff 
##                    0.0529849037                   -0.0095520713 
## YOB.Age.fctr(20,25]:YOB.Age.dff YOB.Age.fctr(30,35]:YOB.Age.dff 
##                    0.0380836715                    0.0007277624 
## YOB.Age.fctr(35,40]:YOB.Age.dff YOB.Age.fctr(50,65]:YOB.Age.dff 
##                   -0.0559077872                    0.0011994690 
## [1] "max lambda < lambdaOpt:"
##                     (Intercept)                          .rnorm 
##                   -0.2042215154                    0.0110033826 
##                      Edn.fctr.L                      Edn.fctr.Q 
##                   -0.0407535860                    0.2079840401 
##                      Edn.fctr.C                      Edn.fctr^4 
##                    0.0689773125                    0.2826726986 
##                      Edn.fctr^5                      Edn.fctr^6 
##                    0.1464772124                   -0.1183788701 
##                      Edn.fctr^7                    Gender.fctrF 
##                   -0.1128134156                   -0.0569927606 
##                    Gender.fctrM                   Hhold.fctrMKn 
##                    0.2613700236                   -0.0340465279 
##                   Hhold.fctrMKy                   Hhold.fctrPKn 
##                    0.1250932456                   -0.1324040847 
##                   Hhold.fctrPKy                   Hhold.fctrSKn 
##                    0.8427118661                   -0.1065239644 
##                   Income.fctr.Q                   Income.fctr.C 
##                   -0.0433564845                    0.2245743194 
##                   Income.fctr^4                   Income.fctr^6 
##                    0.1690514741                    0.1035263211 
##                  Q100010.fctrNo                  Q100562.fctrNo 
##                   -0.2497298160                    0.4822464108 
##                  Q100680.fctrNo                  Q100689.fctrNo 
##                   -0.1807830733                   -0.0647345148 
##                 Q100689.fctrYes            Q101162.fctrOptimist 
##                   -0.4354990734                   -0.1251457575 
##           Q101162.fctrPessimist                 Q101163.fctrDad 
##                    0.2573593714                    0.1172833908 
##                 Q101163.fctrMom                  Q101596.fctrNo 
##                   -0.4945961607                    0.1087885277 
##                 Q101596.fctrYes                 Q102089.fctrOwn 
##                    0.4128297303                   -0.2147991379 
##                Q102089.fctrRent                  Q102289.fctrNo 
##                   -0.2919544016                    0.0001903800 
##                 Q102289.fctrYes                  Q102674.fctrNo 
##                   -0.1454758031                    0.1577531073 
##                 Q102674.fctrYes                  Q102687.fctrNo 
##                   -0.3575013519                    0.0555808641 
##                 Q102687.fctrYes                 Q102906.fctrYes 
##                   -0.0767038930                    0.0470276115 
##                  Q103293.fctrNo                  Q104996.fctrNo 
##                    0.0781027425                    0.2166326190 
##                 Q104996.fctrYes                  Q105840.fctrNo 
##                   -0.0773991883                    0.0566444393 
##                  Q106042.fctrNo                 Q106042.fctrYes 
##                    0.1221072904                    0.0505755621 
##                  Q106272.fctrNo                 Q106272.fctrYes 
##                    0.1430131668                    0.1034509121 
##                  Q106388.fctrNo                 Q106388.fctrYes 
##                    0.2423010549                   -0.1649205548 
##                  Q106389.fctrNo                 Q106389.fctrYes 
##                    0.2497812152                   -0.2324070448 
##                  Q106993.fctrNo                  Q106997.fctrGr 
##                    0.1060524232                   -0.0256856757 
##                  Q107491.fctrNo                 Q107491.fctrYes 
##                    0.1283373652                   -0.2132433214 
##                 Q107869.fctrYes           Q108342.fctrIn-person 
##                    0.0554856661                   -0.0845621306 
##              Q108342.fctrOnline                 Q108343.fctrYes 
##                   -0.2249534075                   -0.0461991115 
##                  Q108617.fctrNo              Q108855.fctrUmm... 
##                    0.2112492992                    0.2597989499 
##           Q108856.fctrSocialize               Q108856.fctrSpace 
##                    0.3726724796                   -0.0934508530 
##            Q108950.fctrCautious       Q108950.fctrRisk-friendly 
##                    0.0209520003                   -0.4618005866 
##                  Q109367.fctrNo                 Q109367.fctrYes 
##                   -0.2612690315                   -0.1464939533 
##                 Q110740.fctrMac                  Q110740.fctrPC 
##                    0.1738408055                    0.2542117819 
##          Q111580.fctrSupportive                  Q111848.fctrNo 
##                   -0.0262842836                   -0.1709111869 
##                 Q111848.fctrYes                  Q112270.fctrNo 
##                   -0.0685689192                   -0.0876659551 
##                 Q112270.fctrYes                  Q112478.fctrNo 
##                   -0.2939542323                    0.3188201052 
##                  Q112512.fctrNo                 Q112512.fctrYes 
##                    0.2055846712                    0.0153057985 
##                  Q113181.fctrNo                 Q113181.fctrYes 
##                   -0.0859642777                    0.4543692335 
##               Q113583.fctrTunes              Q113584.fctrPeople 
##                   -0.3388685080                   -0.0599830235 
##                  Q113992.fctrNo                 Q113992.fctrYes 
##                    0.0008891958                   -0.0491056144 
##                 Q114152.fctrYes          Q114386.fctrMysterious 
##                   -0.0265516379                    0.1644845244 
##                 Q114386.fctrTMI                  Q114517.fctrNo 
##                   -0.1016342007                   -0.0946559549 
##                  Q114748.fctrNo                  Q114961.fctrNo 
##                   -0.0384019420                   -0.0477093360 
##                 Q114961.fctrYes                  Q115195.fctrNo 
##                    0.1431035859                    0.1557333819 
##                 Q115195.fctrYes                  Q115390.fctrNo 
##                   -0.2123021468                    0.3027408691 
##                  Q115602.fctrNo                  Q115610.fctrNo 
##                   -0.0640768047                   -0.1784536320 
##                 Q115610.fctrYes                  Q115611.fctrNo 
##                    0.0174654126                   -0.2247446841 
##                 Q115611.fctrYes                 Q115777.fctrEnd 
##                    0.4576956505                   -0.1673792971 
##               Q115777.fctrStart                  Q115899.fctrCs 
##                    0.0973576291                   -0.2523686313 
##                  Q115899.fctrMe                Q116197.fctrA.M. 
##                    0.0543933192                    0.0049360502 
##                Q116197.fctrP.M.                  Q116441.fctrNo 
##                    0.1843352482                   -0.2705357971 
##                 Q116441.fctrYes                  Q116448.fctrNo 
##                    0.2729089647                    0.1479006520 
##                 Q116448.fctrYes                  Q116601.fctrNo 
##                    0.0284532479                    0.4042380994 
##                 Q116601.fctrYes                  Q116797.fctrNo 
##                   -0.1624763418                    0.2119695928 
##                 Q116797.fctrYes               Q116881.fctrRight 
##                    0.1026620688                    0.0954780346 
##                  Q116953.fctrNo                 Q116953.fctrYes 
##                   -0.1051046755                   -0.1408018255 
##         Q117186.fctrCool headed          Q117186.fctrHot headed 
##                   -0.1599530380                    0.0933606533 
##           Q117193.fctrOdd hours      Q117193.fctrStandard hours 
##                    0.0101251009                    0.0248498133 
##                 Q118117.fctrYes                  Q118232.fctrId 
##                    0.1411799747                   -0.1097789192 
##                  Q118232.fctrPr                  Q118233.fctrNo 
##                   -0.1952338167                    0.0853911725 
##                  Q118237.fctrNo                  Q118892.fctrNo 
##                    0.0249080102                    0.0264262118 
##                 Q118892.fctrYes                  Q119334.fctrNo 
##                   -0.1407485238                   -0.0494285992 
##                 Q119334.fctrYes              Q119650.fctrGiving 
##                    0.0703300486                    0.0686769745 
##           Q119650.fctrReceiving                  Q119851.fctrNo 
##                    0.0706271999                    0.1751164459 
##                 Q119851.fctrYes                  Q120012.fctrNo 
##                   -0.0627341858                    0.1145143639 
##                  Q120014.fctrNo                 Q120014.fctrYes 
##                   -0.1549489773                   -0.0459374164 
##         Q120194.fctrStudy first                  Q120379.fctrNo 
##                   -0.2134879405                    0.0967227141 
##                 Q120379.fctrYes             Q120472.fctrScience 
##                   -0.2857107062                    0.1559831300 
##                  Q120650.fctrNo                 Q120650.fctrYes 
##                   -0.3796161377                    0.1298048266 
##                 Q120978.fctrYes                  Q121011.fctrNo 
##                   -0.1290096303                    0.1207855872 
##                  Q121699.fctrNo                 Q121699.fctrYes 
##                   -0.0767141039                   -0.1246031523 
##                  Q121700.fctrNo                 Q121700.fctrYes 
##                   -0.0113964002                   -0.1363632464 
##                 Q122120.fctrYes                  Q122770.fctrNo 
##                    0.2129454216                   -0.0642135394 
##                  Q122771.fctrPc                  Q122771.fctrPt 
##                   -0.0239283208                    0.3257289966 
##                 Q123464.fctrYes                  Q123621.fctrNo 
##                   -0.4927230091                    0.1193495826 
##                  Q124122.fctrNo                 Q124122.fctrYes 
##                    0.0672896213                   -0.0197566114 
##                 Q124742.fctrYes                   Q96024.fctrNo 
##                    0.0715148917                   -0.0378783761 
##                  Q96024.fctrYes           Q98059.fctrOnly-child 
##                    0.0892791856                    0.3541652414 
##                  Q98059.fctrYes                   Q98078.fctrNo 
##                   -0.0535209754                   -0.0285855529 
##                   Q98197.fctrNo                  Q98197.fctrYes 
##                   -0.5484798718                    0.2004404463 
##                   Q98578.fctrNo                  Q98578.fctrYes 
##                    0.1714068228                    0.1946642199 
##                   Q98869.fctrNo                  Q98869.fctrYes 
##                   -0.4198941963                   -0.0086465251 
##                   Q99480.fctrNo                  Q99480.fctrYes 
##                   -0.1589510915                    0.3838616651 
##                  Q99581.fctrYes                   Q99716.fctrNo 
##                    0.0657754933                   -0.1971125317 
##               Q99982.fctrCheck!                  YOB.Age.fctr.L 
##                    0.0856839080                   -0.3267835649 
##                  YOB.Age.fctr.Q                  YOB.Age.fctr.C 
##                   -0.2768584499                   -0.1165077129 
##                  YOB.Age.fctr^4                  YOB.Age.fctr^5 
##                   -0.0636431883                   -0.0281297225 
##                  YOB.Age.fctr^7                  YOB.Age.fctr^8 
##                    0.1326176210                    0.0854443056 
## Q109244.fctrNA:.clusterid.fctr2 Q109244.fctrNA:.clusterid.fctr3 
##                   -0.0190978510                    0.0643226511 
## YOB.Age.fctr(15,20]:YOB.Age.dff YOB.Age.fctr(20,25]:YOB.Age.dff 
##                   -0.0130045917                    0.0406687854 
## YOB.Age.fctr(30,35]:YOB.Age.dff YOB.Age.fctr(35,40]:YOB.Age.dff 
##                    0.0025499774                   -0.0564718198 
## YOB.Age.fctr(50,65]:YOB.Age.dff 
##                    0.0020418886 
## [1] "myfit_mdl: train diagnostics complete: 8.690000 secs"

##          Prediction
## Reference   D   R
##         D 595 341
##         R 208 602
##       Accuracy          Kappa  AccuracyLower  AccuracyUpper   AccuracyNull 
##   6.855670e-01   3.747520e-01   6.632044e-01   7.073043e-01   5.360825e-01 
## AccuracyPValue  McnemarPValue 
##   3.240583e-37   1.764628e-08

##          Prediction
## Reference   D   R
##         D 112 123
##         R  58 145
##       Accuracy          Kappa  AccuracyLower  AccuracyUpper   AccuracyNull 
##   5.867580e-01   1.868089e-01   5.390441e-01   6.332921e-01   5.365297e-01 
## AccuracyPValue  McnemarPValue 
##   1.945046e-02   1.964109e-06 
## [1] "myfit_mdl: predict complete: 17.669000 secs"
##                  id
## 1 All.X##rcv#glmnet
##                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             feats
## 1 Gender.fctr,Q113181.fctr,Q120472.fctr,Q115611.fctr,Q120650.fctr,Q118237.fctr,.rnorm,Q122120.fctr,Q110740.fctr,Q122770.fctr,Q118117.fctr,Income.fctr,Q116441.fctr,Q118233.fctr,Q106272.fctr,Q119650.fctr,Q124742.fctr,Q122771.fctr,Q99480.fctr,Q116197.fctr,Q116881.fctr,Q101596.fctr,Q122769.fctr,Q108855.fctr,Q120014.fctr,Q119334.fctr,Q106993.fctr,Q107869.fctr,Q121011.fctr,Q117186.fctr,Q106997.fctr,Q108617.fctr,Q98197.fctr,Q106042.fctr,Q115777.fctr,Q123621.fctr,Q106388.fctr,Q114152.fctr,Q124122.fctr,Q120194.fctr,Q116797.fctr,Q105655.fctr,Q115899.fctr,Q116448.fctr,Q117193.fctr,Q108754.fctr,Q108856.fctr,YOB.Age.fctr,Q123464.fctr,Q99581.fctr,Q114961.fctr,Q104996.fctr,Q108343.fctr,Q120012.fctr,Q120978.fctr,Q98578.fctr,Q103293.fctr,Q106389.fctr,Q98869.fctr,Q112512.fctr,Q116953.fctr,Q100010.fctr,Q111220.fctr,Q102906.fctr,Q121700.fctr,Q112478.fctr,Q115610.fctr,Q119851.fctr,Q114517.fctr,Q118892.fctr,Q115602.fctr,Q120379.fctr,Q107491.fctr,Q114748.fctr,Q99982.fctr,Q113992.fctr,Q115390.fctr,Q118232.fctr,Q96024.fctr,Q115195.fctr,Q121699.fctr,Q100680.fctr,Q111580.fctr,Q102289.fctr,Q102687.fctr,Q105840.fctr,Q101162.fctr,Q108950.fctr,Q116601.fctr,Q108342.fctr,Q100562.fctr,Q113584.fctr,Q109367.fctr,Q99716.fctr,Hhold.fctr,Q112270.fctr,Q98059.fctr,Q111848.fctr,Q102674.fctr,Q114386.fctr,Q98078.fctr,Q102089.fctr,Edn.fctr,Q100689.fctr,Q113583.fctr,Q101163.fctr,YOB.Age.fctr:YOB.Age.dff,Q109244.fctr:.clusterid.fctr
##   max.nTuningRuns min.elapsedtime.everything min.elapsedtime.final
## 1              25                      7.303                 0.691
##   max.AUCpROC.fit max.Sens.fit max.Spec.fit max.AUCROCR.fit
## 1       0.6789055    0.7553419    0.6024691       0.7573718
##   opt.prob.threshold.fit max.f.score.fit max.Accuracy.fit
## 1                   0.45       0.6868226        0.5689194
##   max.AccuracyLower.fit max.AccuracyUpper.fit max.Kappa.fit
## 1             0.6632044             0.7073043     0.1280509
##   max.AUCpROC.OOB max.Sens.OOB max.Spec.OOB max.AUCROCR.OOB
## 1       0.5683681    0.6638298    0.4729064       0.6153233
##   opt.prob.threshold.OOB max.f.score.OOB max.Accuracy.OOB
## 1                    0.4       0.6157113         0.586758
##   max.AccuracyLower.OOB max.AccuracyUpper.OOB max.Kappa.OOB
## 1             0.5390441             0.6332921     0.1868089
##   max.AccuracySD.fit max.KappaSD.fit
## 1         0.01451469      0.02957011
## [1] "myfit_mdl: exit: 17.938000 secs"
##                  label step_major step_minor label_minor     bgn     end
## 3   fit.models_1_All.X          1          2      glmnet 352.081 370.044
## 4 fit.models_1_preProc          1          3     preProc 370.045      NA
##   elapsed
## 3  17.963
## 4      NA
##                                 min.elapsedtime.everything
## Random###myrandom_classfr                            0.381
## MFO###myMFO_classfr                                  0.485
## Max.cor.Y.rcv.1X1###glmnet                           0.710
## Max.cor.Y##rcv#rpart                                 1.464
## Interact.High.cor.Y##rcv#glmnet                      2.492
## Low.cor.X##rcv#glmnet                                6.595
## All.X##rcv#glmnet                                    7.303
##                  label step_major step_minor label_minor     bgn    end
## 4 fit.models_1_preProc          1          3     preProc 370.045 370.09
## 5     fit.models_1_end          1          4    teardown 370.091     NA
##   elapsed
## 4   0.045
## 5      NA
##         label step_major step_minor label_minor    bgn     end elapsed
## 17 fit.models          8          1           1 347.34 370.099   22.76
## 18 fit.models          8          2           2 370.10      NA      NA

```{r fit.models_2, cache=FALSE, fig.height=10, fig.width=15, eval=myevlChunk(glbChunks, glbOut$pfx)}

##              label step_major step_minor label_minor     bgn end elapsed
## 1 fit.models_2_bgn          1          0       setup 371.243  NA      NA
## Warning: max.AccuracyUpper.fit already exists in glb_models_df
## [1] "var:max.KappaSD.fit"
## Warning: Removed 3 rows containing missing values (geom_errorbar).
## quartz_off_screen 
##                 2
## Warning: Removed 3 rows containing missing values (geom_errorbar).

##                                id max.Accuracy.OOB max.AUCROCR.OOB
## 7               All.X##rcv#glmnet        0.5867580       0.6153233
## 6           Low.cor.X##rcv#glmnet        0.5730594       0.6077246
## 5 Interact.High.cor.Y##rcv#glmnet        0.5662100       0.5851273
## 3      Max.cor.Y.rcv.1X1###glmnet        0.5410959       0.5584215
## 4            Max.cor.Y##rcv#rpart        0.5410959       0.5448590
## 2       Random###myrandom_classfr        0.5365297       0.5042029
## 1             MFO###myMFO_classfr        0.5365297       0.5000000
##   max.AUCpROC.OOB min.elapsedtime.everything max.Accuracy.fit
## 7       0.5683681                      7.303        0.5689194
## 6       0.5571848                      6.595        0.5631921
## 5       0.5598575                      2.492        0.5578465
## 3       0.5441673                      0.710        0.5595647
## 4       0.5441673                      1.464        0.5595647
## 2       0.5576145                      0.381        0.5360825
## 1       0.5000000                      0.485        0.5360825
##   opt.prob.threshold.fit opt.prob.threshold.OOB
## 7                   0.45                   0.40
## 6                   0.45                   0.50
## 5                   0.50                   0.50
## 3                   0.50                   0.50
## 4                   0.50                   0.50
## 2                   0.55                   0.55
## 1                   0.50                   0.50
## [1] "Metrics used for model selection:"
## ~-max.Accuracy.OOB - max.AUCROCR.OOB - max.AUCpROC.OOB + min.elapsedtime.everything - 
##     max.Accuracy.fit - opt.prob.threshold.OOB
## <environment: 0x7ff638d95400>
## [1] "Best model id: All.X##rcv#glmnet"
## glmnet 
## 
## 1746 samples
##  109 predictor
##    2 classes: 'D', 'R' 
## 
## No pre-processing
## Resampling: Cross-Validated (3 fold, repeated 3 times) 
## Summary of sample sizes: 1164, 1164, 1164, 1164, 1164, 1164, ... 
## Resampling results across tuning parameters:
## 
##   alpha  lambda        Accuracy   Kappa     
##   0.100  5.319575e-05  0.5515464  0.09709774
##   0.100  2.469128e-04  0.5515464  0.09709774
##   0.100  1.146068e-03  0.5544101  0.10259571
##   0.100  5.319575e-03  0.5610920  0.11485313
##   0.100  2.469128e-02  0.5689194  0.12805093
##   0.325  5.319575e-05  0.5517373  0.09751032
##   0.325  2.469128e-04  0.5517373  0.09745873
##   0.325  1.146068e-03  0.5563192  0.10619634
##   0.325  5.319575e-03  0.5620466  0.11614994
##   0.325  2.469128e-02  0.5610920  0.10795427
##   0.550  5.319575e-05  0.5525010  0.09894666
##   0.550  2.469128e-04  0.5523100  0.09853826
##   0.550  1.146068e-03  0.5584192  0.11035572
##   0.550  5.319575e-03  0.5635739  0.11803988
##   0.550  2.469128e-02  0.5666285  0.11464516
##   0.775  5.319575e-05  0.5519282  0.09776565
##   0.775  2.469128e-04  0.5534555  0.10069456
##   0.775  1.146068e-03  0.5574647  0.10792503
##   0.775  5.319575e-03  0.5637648  0.11765608
##   0.775  2.469128e-02  0.5668194  0.10887915
##   1.000  5.319575e-05  0.5515464  0.09694706
##   1.000  2.469128e-04  0.5536464  0.10110872
##   1.000  1.146068e-03  0.5572738  0.10745141
##   1.000  5.319575e-03  0.5668194  0.12271698
##   1.000  2.469128e-02  0.5641466  0.09678870
## 
## Accuracy was used to select the optimal model using  the largest value.
## The final values used for the model were alpha = 0.1 and lambda
##  = 0.02469128.
## [1] "All.X##rcv#glmnet fit prediction diagnostics:"
## [1] "All.X##rcv#glmnet OOB prediction diagnostics:"
##                                  All.X..rcv.glmnet.imp          imp
## Hhold.fctrPKy                             100.00000000 100.00000000
## Q98197.fctrNo                              65.04828571  65.04828571
## Q101163.fctrMom                            58.70889930  58.70889930
## Q123464.fctrYes                            58.37654216  58.37654216
## Q100562.fctrNo                             56.99103709  56.99103709
## Q108950.fctrRisk-friendly                  54.82548652  54.82548652
## Q115611.fctrYes                            54.36119266  54.36119266
## Q113181.fctrYes                            53.87955132  53.87955132
## Q100689.fctrYes                            51.33794846  51.33794846
## Q98869.fctrNo                              49.75750190  49.75750190
## Q101596.fctrYes                            48.66777819  48.66777819
## Q116601.fctrNo                             48.16811052  48.16811052
## Q99480.fctrYes                             45.37060282  45.37060282
## Q120650.fctrNo                             45.12703792  45.12703792
## Q108856.fctrSocialize                      44.04979703  44.04979703
## Q102674.fctrYes                            42.37404254  42.37404254
## Q98059.fctrOnly-child                      41.81605007  41.81605007
## Q113583.fctrTunes                          40.14270897  40.14270897
## Q122771.fctrPt                             38.59326056  38.59326056
## YOB.Age.fctr.L                             38.50461782  38.50461782
## Q112478.fctrNo                             37.76366344  37.76366344
## Q115390.fctrNo                             35.85133428  35.85133428
## Q112270.fctrYes                            34.69973543  34.69973543
## Q102089.fctrRent                           34.32823140  34.32823140
## Q120379.fctrYes                            33.89015581  33.89015581
## Edn.fctr^4                                 33.47414357  33.47414357
## YOB.Age.fctr.Q                             32.72523076  32.72523076
## Q116441.fctrYes                            32.56134900  32.56134900
## Q116441.fctrNo                             31.96112168  31.96112168
## Gender.fctrM                               30.99175680  30.99175680
## Q109367.fctrNo                             30.76271919  30.76271919
## Q108855.fctrUmm...                         30.65122953  30.65122953
## Q101162.fctrPessimist                      30.46431892  30.46431892
## Q110740.fctrPC                             29.99555729  29.99555729
## Q115899.fctrCs                             29.83100896  29.83100896
## Q106389.fctrNo                             29.79700650  29.79700650
## Q100010.fctrNo                             29.53498245  29.53498245
## Q106388.fctrNo                             28.71415220  28.71415220
## Q106389.fctrYes                            27.24662484  27.24662484
## Q115611.fctrNo                             26.63256892  26.63256892
## Income.fctr.C                              26.58502973  26.58502973
## Q108342.fctrOnline                         26.51987332  26.51987332
## Q104996.fctrNo                             25.76255553  25.76255553
## Q120194.fctrStudy first                    25.25057298  25.25057298
## Q102089.fctrOwn                            25.19677217  25.19677217
## Q122120.fctrYes                            25.14327685  25.14327685
## Q107491.fctrYes                            25.10716089  25.10716089
## Q115195.fctrYes                            25.00880052  25.00880052
## Q108617.fctrNo                             24.86148060  24.86148060
## Q116797.fctrNo                             24.84439074  24.84439074
## Edn.fctr.Q                                 24.48897959  24.48897959
## Q112512.fctrNo                             24.13237615  24.13237615
## Q98197.fctrYes                             23.92002846  23.92002846
## Q99716.fctrNo                              23.15453176  23.15453176
## Q118232.fctrPr                             23.05912330  23.05912330
## Q98578.fctrYes                             22.69548452  22.69548452
## Q116197.fctrP.M.                           21.74573471  21.74573471
## Q100680.fctrNo                             21.32491293  21.32491293
## Q115610.fctrNo                             21.26751769  21.26751769
## Q119851.fctrNo                             20.74322494  20.74322494
## Q110740.fctrMac                            20.43226420  20.43226420
## Q111848.fctrNo                             20.14164588  20.14164588
## Q98578.fctrNo                              20.02779169  20.02779169
## Income.fctr^4                              19.96596182  19.96596182
## Q115777.fctrEnd                            19.74269986  19.74269986
## Q114386.fctrMysterious                     19.45040116  19.45040116
## Q106388.fctrYes                            19.44404023  19.44404023
## Q116601.fctrYes                            19.11653953  19.11653953
## Q99480.fctrNo                              19.02748347  19.02748347
## Q117186.fctrCool headed                    18.79970907  18.79970907
## Q102674.fctrNo                             18.68634335  18.68634335
## Q115195.fctrNo                             18.53860388  18.53860388
## Q120472.fctrScience                        18.46387937  18.46387937
## Q120014.fctrNo                             18.25595493  18.25595493
## Q116448.fctrNo                             17.38150488  17.38150488
## Q109367.fctrYes                            17.30956652  17.30956652
## Edn.fctr^5                                 17.18869620  17.18869620
## Q102289.fctrYes                            17.16212334  17.16212334
## Q114961.fctrYes                            16.79250041  16.79250041
## Q106272.fctrNo                             16.77475600  16.77475600
## Q118117.fctrYes                            16.71307330  16.71307330
## Q118892.fctrYes                            16.65291627  16.65291627
## Q116953.fctrYes                            16.38551337  16.38551337
## Q121700.fctrYes                            16.10352224  16.10352224
## Hhold.fctrPKn                              15.64519624  15.64519624
## YOB.Age.fctr^7                             15.50614515  15.50614515
## Q120978.fctrYes                            15.30358299  15.30358299
## Q120650.fctrYes                            15.29265166  15.29265166
## Q107491.fctrNo                             15.26966483  15.26966483
## Hhold.fctrMKy                              14.86167522  14.86167522
## Q101162.fctrOptimist                       14.79344561  14.79344561
## Q121699.fctrYes                            14.69471751  14.69471751
## Q106042.fctrNo                             14.31677466  14.31677466
## Q121011.fctrNo                             14.27787962  14.27787962
## Edn.fctr^6                                 14.02376046  14.02376046
## Q123621.fctrNo                             13.99411708  13.99411708
## Q101163.fctrDad                            13.87998117  13.87998117
## YOB.Age.fctr.C                             13.67668034  13.67668034
## Q120012.fctrNo                             13.53443016  13.53443016
## Edn.fctr^7                                 13.33454917  13.33454917
## Q118232.fctrId                             12.82468958  12.82468958
## Q101596.fctrNo                             12.59209022  12.59209022
## Hhold.fctrSKn                              12.58809153  12.58809153
## Q106993.fctrNo                             12.46648755  12.46648755
## Income.fctr^6                              12.20797580  12.20797580
## Q106272.fctrYes                            12.09566958  12.09566958
## Q114386.fctrTMI                            12.09039160  12.09039160
## Q116953.fctrNo                             12.04415904  12.04415904
## Q116797.fctrYes                            11.90204138  11.90204138
## Q115777.fctrStart                          11.56229740  11.56229740
## Q120379.fctrNo                             11.45508668  11.45508668
## Q116881.fctrRight                          11.31786995  11.31786995
## Q117186.fctrHot headed                     11.14929669  11.14929669
## Q114517.fctrNo                             11.12476612  11.12476612
## Q108856.fctrSpace                          10.95016791  10.95016791
## Q96024.fctrYes                             10.51724456  10.51724456
## Q113181.fctrNo                             10.21655090  10.21655090
## YOB.Age.fctr^8                             10.19324341  10.19324341
## Q112270.fctrNo                             10.16978124  10.16978124
## Q99982.fctrCheck!                           9.99813228   9.99813228
## Q118233.fctrNo                              9.98753273   9.98753273
## Q108342.fctrIn-person                       9.87207559   9.87207559
## Q103293.fctrNo                              9.13975875   9.13975875
## Q102687.fctrYes                             9.10956985   9.10956985
## Q104996.fctrYes                             9.06503107   9.06503107
## Q121699.fctrNo                              8.90787235   8.90787235
## Q124742.fctrYes                             8.43567189   8.43567189
## Q119334.fctrYes                             8.31937455   8.31937455
## Q119650.fctrReceiving                       8.14856004   8.14856004
## Q111848.fctrYes                             8.04210993   8.04210993
## Q124122.fctrNo                              7.97783846   7.97783846
## Edn.fctr.C                                  7.94753921   7.94753921
## Q119650.fctrGiving                          7.93463365   7.93463365
## Q99581.fctrYes                              7.63612487   7.63612487
## Q122770.fctrNo                              7.53984667   7.53984667
## Q115602.fctrNo                              7.49895999   7.49895999
## Q119851.fctrYes                             7.49822551   7.49822551
## Q100689.fctrNo                              7.40909895   7.40909895
## Q109244.fctrNA:.clusterid.fctr3             7.40697169   7.40697169
## YOB.Age.fctr^4                              7.32963244   7.32963244
## Q113584.fctrPeople                          6.97987555   6.97987555
## Gender.fctrF                                6.85183036   6.85183036
## Q105840.fctrNo                              6.75070028   6.75070028
## YOB.Age.fctr(35,40]:YOB.Age.dff             6.71908081   6.71908081
## Q115899.fctrMe                              6.43902811   6.43902811
## Q102687.fctrNo                              6.38732137   6.38732137
## Q98059.fctrYes                              6.35401501   6.35401501
## Q107869.fctrYes                             6.34735376   6.34735376
## Q106042.fctrYes                             5.86829658   5.86829658
## Q119334.fctrNo                              5.77603390   5.77603390
## Q113992.fctrYes                             5.76189801   5.76189801
## Q114961.fctrNo                              5.64204447   5.64204447
## Q102906.fctrYes                             5.47225482   5.47225482
## Q108343.fctrYes                             5.38349362   5.38349362
## Q120014.fctrYes                             5.26971744   5.26971744
## Income.fctr.Q                               5.01776984   5.01776984
## Edn.fctr.L                                  4.93985986   4.93985986
## YOB.Age.fctr(20,25]:YOB.Age.dff             4.78865841   4.78865841
## Q96024.fctrNo                               4.51911502   4.51911502
## Q114748.fctrNo                              4.44030358   4.44030358
## Hhold.fctrMKn                               3.96941185   3.96941185
## YOB.Age.fctr^5                              3.32559612   3.32559612
## Q98078.fctrNo                               3.22890502   3.22890502
## Q116448.fctrYes                             3.16653709   3.16653709
## Q118892.fctrNo                              3.16183870   3.16183870
## Q111580.fctrSupportive                      3.08478749   3.08478749
## Q114152.fctrYes                             2.97986267   2.97986267
## Q118237.fctrNo                              2.91954724   2.91954724
## Q106997.fctrGr                              2.91187343   2.91187343
## Q122771.fctrPc                              2.84528130   2.84528130
## Q117193.fctrStandard hours                  2.69447397   2.69447397
## Q108950.fctrCautious                        2.44007671   2.44007671
## Q124122.fctrYes                             2.30458741   2.30458741
## Q109244.fctrNA:.clusterid.fctr2             2.09361358   2.09361358
## Q115610.fctrYes                             1.87689570   1.87689570
## Q112512.fctrYes                             1.54061708   1.54061708
## YOB.Age.fctr(15,20]:YOB.Age.dff             1.47081274   1.47081274
## .rnorm                                      1.31590903   1.31590903
## Q121700.fctrNo                              1.26704991   1.26704991
## Q117193.fctrOdd hours                       0.97986083   0.97986083
## Q98869.fctrYes                              0.83171509   0.83171509
## Q116197.fctrA.M.                            0.47480200   0.47480200
## YOB.Age.fctr(30,35]:YOB.Age.dff             0.26203741   0.26203741
## YOB.Age.fctr(50,65]:YOB.Age.dff             0.22402287   0.22402287
## Q113992.fctrNo                              0.12317152   0.12317152
## Q102289.fctrNo                              0.01831279   0.01831279
## Hhold.fctrSKy                               0.00000000   0.00000000
## Income.fctr.L                               0.00000000   0.00000000
## Income.fctr^5                               0.00000000   0.00000000
## Q100010.fctrYes                             0.00000000   0.00000000
## Q100562.fctrYes                             0.00000000   0.00000000
## Q100680.fctrYes                             0.00000000   0.00000000
## Q102906.fctrNo                              0.00000000   0.00000000
## Q103293.fctrYes                             0.00000000   0.00000000
## Q105655.fctrNo                              0.00000000   0.00000000
## Q105655.fctrYes                             0.00000000   0.00000000
## Q105840.fctrYes                             0.00000000   0.00000000
## Q106993.fctrYes                             0.00000000   0.00000000
## Q106997.fctrYy                              0.00000000   0.00000000
## Q107869.fctrNo                              0.00000000   0.00000000
## Q108343.fctrNo                              0.00000000   0.00000000
## Q108617.fctrYes                             0.00000000   0.00000000
## Q108754.fctrNo                              0.00000000   0.00000000
## Q108754.fctrYes                             0.00000000   0.00000000
## Q108855.fctrYes!                            0.00000000   0.00000000
## Q111220.fctrNo                              0.00000000   0.00000000
## Q111220.fctrYes                             0.00000000   0.00000000
## Q111580.fctrDemanding                       0.00000000   0.00000000
## Q112478.fctrYes                             0.00000000   0.00000000
## Q113583.fctrTalk                            0.00000000   0.00000000
## Q113584.fctrTechnology                      0.00000000   0.00000000
## Q114152.fctrNo                              0.00000000   0.00000000
## Q114517.fctrYes                             0.00000000   0.00000000
## Q114748.fctrYes                             0.00000000   0.00000000
## Q115390.fctrYes                             0.00000000   0.00000000
## Q115602.fctrYes                             0.00000000   0.00000000
## Q116881.fctrHappy                           0.00000000   0.00000000
## Q118117.fctrNo                              0.00000000   0.00000000
## Q118233.fctrYes                             0.00000000   0.00000000
## Q118237.fctrYes                             0.00000000   0.00000000
## Q120012.fctrYes                             0.00000000   0.00000000
## Q120194.fctrTry first                       0.00000000   0.00000000
## Q120472.fctrArt                             0.00000000   0.00000000
## Q120978.fctrNo                              0.00000000   0.00000000
## Q121011.fctrYes                             0.00000000   0.00000000
## Q122120.fctrNo                              0.00000000   0.00000000
## Q122769.fctrNo                              0.00000000   0.00000000
## Q122769.fctrYes                             0.00000000   0.00000000
## Q122770.fctrYes                             0.00000000   0.00000000
## Q123464.fctrNo                              0.00000000   0.00000000
## Q123621.fctrYes                             0.00000000   0.00000000
## Q124742.fctrNo                              0.00000000   0.00000000
## Q98078.fctrYes                              0.00000000   0.00000000
## Q99581.fctrNo                               0.00000000   0.00000000
## Q99716.fctrYes                              0.00000000   0.00000000
## Q99982.fctrNope                             0.00000000   0.00000000
## YOB.Age.fctr^6                              0.00000000   0.00000000
## Q109244.fctrNA:.clusterid.fctr1             0.00000000   0.00000000
## Q109244.fctrNo:.clusterid.fctr1             0.00000000   0.00000000
## Q109244.fctrYes:.clusterid.fctr1            0.00000000   0.00000000
## Q109244.fctrNo:.clusterid.fctr2             0.00000000   0.00000000
## Q109244.fctrYes:.clusterid.fctr2            0.00000000   0.00000000
## Q109244.fctrNo:.clusterid.fctr3             0.00000000   0.00000000
## Q109244.fctrYes:.clusterid.fctr3            0.00000000   0.00000000
## Q109244.fctrNA:.clusterid.fctr4             0.00000000   0.00000000
## Q109244.fctrNo:.clusterid.fctr4             0.00000000   0.00000000
## Q109244.fctrYes:.clusterid.fctr4            0.00000000   0.00000000
## YOB.Age.fctrNA:YOB.Age.dff                  0.00000000   0.00000000
## YOB.Age.fctr(25,30]:YOB.Age.dff             0.00000000   0.00000000
## YOB.Age.fctr(40,50]:YOB.Age.dff             0.00000000   0.00000000
## YOB.Age.fctr(65,90]:YOB.Age.dff             0.00000000   0.00000000
## Warning in glb_analytics_diag_plots(obs_df = glbObsOOB, mdl_id =
## glbMdlSelId, : Limiting important feature scatter plots to 5 out of 108

## [1] "Min/Max Boundaries: "
## [1] "Inaccurate: "
##   USER_ID Party.fctr Party.fctr.All.X..rcv.glmnet.prob
## 1    1792          R                         0.1026305
## 2    6339          R                         0.1723108
## 3    2250          R                         0.1931380
## 4    5299          R                         0.2032839
## 5    6098          R                         0.2165230
## 6    2774          R                         0.2180307
##   Party.fctr.All.X..rcv.glmnet Party.fctr.All.X..rcv.glmnet.err
## 1                            D                             TRUE
## 2                            D                             TRUE
## 3                            D                             TRUE
## 4                            D                             TRUE
## 5                            D                             TRUE
## 6                            D                             TRUE
##   Party.fctr.All.X..rcv.glmnet.err.abs Party.fctr.All.X..rcv.glmnet.is.acc
## 1                            0.8973695                               FALSE
## 2                            0.8276892                               FALSE
## 3                            0.8068620                               FALSE
## 4                            0.7967161                               FALSE
## 5                            0.7834770                               FALSE
## 6                            0.7819693                               FALSE
##   Party.fctr.All.X..rcv.glmnet.accurate Party.fctr.All.X..rcv.glmnet.error
## 1                                 FALSE                         -0.2973695
## 2                                 FALSE                         -0.2276892
## 3                                 FALSE                         -0.2068620
## 4                                 FALSE                         -0.1967161
## 5                                 FALSE                         -0.1834770
## 6                                 FALSE                         -0.1819693
##     USER_ID Party.fctr Party.fctr.All.X..rcv.glmnet.prob
## 5      6098          R                         0.2165230
## 48     5421          R                         0.3716921
## 124    1927          D                         0.5574197
## 137    6803          D                         0.5849008
## 141    6604          D                         0.5916924
## 168    5764          D                         0.7034418
##     Party.fctr.All.X..rcv.glmnet Party.fctr.All.X..rcv.glmnet.err
## 5                              D                             TRUE
## 48                             D                             TRUE
## 124                            R                             TRUE
## 137                            R                             TRUE
## 141                            R                             TRUE
## 168                            R                             TRUE
##     Party.fctr.All.X..rcv.glmnet.err.abs
## 5                              0.7834770
## 48                             0.6283079
## 124                            0.5574197
## 137                            0.5849008
## 141                            0.5916924
## 168                            0.7034418
##     Party.fctr.All.X..rcv.glmnet.is.acc
## 5                                 FALSE
## 48                                FALSE
## 124                               FALSE
## 137                               FALSE
## 141                               FALSE
## 168                               FALSE
##     Party.fctr.All.X..rcv.glmnet.accurate
## 5                                   FALSE
## 48                                  FALSE
## 124                                 FALSE
## 137                                 FALSE
## 141                                 FALSE
## 168                                 FALSE
##     Party.fctr.All.X..rcv.glmnet.error
## 5                          -0.18347703
## 48                         -0.02830791
## 124                         0.15741970
## 137                         0.18490082
## 141                         0.19169243
## 168                         0.30344177
##     USER_ID Party.fctr Party.fctr.All.X..rcv.glmnet.prob
## 176    5435          D                         0.8050629
## 177     486          D                         0.8231301
## 178    2888          D                         0.8355269
## 179    6053          D                         0.8572648
## 180    4350          D                         0.9053727
## 181    3431          D                         0.9266629
##     Party.fctr.All.X..rcv.glmnet Party.fctr.All.X..rcv.glmnet.err
## 176                            R                             TRUE
## 177                            R                             TRUE
## 178                            R                             TRUE
## 179                            R                             TRUE
## 180                            R                             TRUE
## 181                            R                             TRUE
##     Party.fctr.All.X..rcv.glmnet.err.abs
## 176                            0.8050629
## 177                            0.8231301
## 178                            0.8355269
## 179                            0.8572648
## 180                            0.9053727
## 181                            0.9266629
##     Party.fctr.All.X..rcv.glmnet.is.acc
## 176                               FALSE
## 177                               FALSE
## 178                               FALSE
## 179                               FALSE
## 180                               FALSE
## 181                               FALSE
##     Party.fctr.All.X..rcv.glmnet.accurate
## 176                                 FALSE
## 177                                 FALSE
## 178                                 FALSE
## 179                                 FALSE
## 180                                 FALSE
## 181                                 FALSE
##     Party.fctr.All.X..rcv.glmnet.error
## 176                          0.4050629
## 177                          0.4231301
## 178                          0.4355269
## 179                          0.4572648
## 180                          0.5053727
## 181                          0.5266629

##    Q109244.fctr .n.OOB .n.Fit .n.Tst .freqRatio.Fit .freqRatio.OOB
## NA           NA    438   1746    547              1              1
##    .freqRatio.Tst err.abs.fit.sum err.abs.fit.mean .n.fit err.abs.OOB.sum
## NA              1        737.9715        0.4226641   1746        202.5673
##    err.abs.OOB.mean
## NA        0.4624824
##           .n.OOB           .n.Fit           .n.Tst   .freqRatio.Fit 
##      438.0000000     1746.0000000      547.0000000        1.0000000 
##   .freqRatio.OOB   .freqRatio.Tst  err.abs.fit.sum err.abs.fit.mean 
##        1.0000000        1.0000000      737.9714939        0.4226641 
##           .n.fit  err.abs.OOB.sum err.abs.OOB.mean 
##     1746.0000000      202.5673105        0.4624824
##              label step_major step_minor label_minor     bgn end elapsed
## 1 fit.models_2_bgn          1          0    teardown 377.571  NA      NA
##         label step_major step_minor label_minor     bgn     end elapsed
## 18 fit.models          8          2           2 370.100 377.582   7.482
## 19 fit.models          8          3           3 377.582      NA      NA
# if (sum(is.na(glbObsAll$D.P.http)) > 0)
#         stop("fit.models_3: Why is this happening ?")

#stop(here"); glb2Sav()
sync_glb_obs_df <- function() {
    # Merge or cbind ?
    for (col in setdiff(names(glbObsFit), names(glbObsTrn)))
        glbObsTrn[glbObsTrn$.lcn == "Fit", col] <<- glbObsFit[, col]
    for (col in setdiff(names(glbObsFit), names(glbObsAll)))
        glbObsAll[glbObsAll$.lcn == "Fit", col] <<- glbObsFit[, col]
    if (all(is.na(glbObsNew[, glb_rsp_var])))
        for (col in setdiff(names(glbObsOOB), names(glbObsTrn)))
            glbObsTrn[glbObsTrn$.lcn == "OOB", col] <<- glbObsOOB[, col]
    for (col in setdiff(names(glbObsOOB), names(glbObsAll)))
        glbObsAll[glbObsAll$.lcn == "OOB", col] <<- glbObsOOB[, col]
}
sync_glb_obs_df()
    
print(setdiff(names(glbObsNew), names(glbObsAll)))
## character(0)
replay.petrisim(pn = glb_analytics_pn, 
    replay.trans = (glb_analytics_avl_objs <- c(glb_analytics_avl_objs, 
        "model.selected")), flip_coord = TRUE)
## time trans    "bgn " "fit.data.training.all " "predict.data.new " "end " 
## 0.0000   multiple enabled transitions:  data.training.all data.new model.selected    firing:  data.training.all 
## 1.0000    1   2 1 0 0 
## 1.0000   multiple enabled transitions:  data.training.all data.new model.selected model.final data.training.all.prediction   firing:  data.new 
## 2.0000    2   1 1 1 0 
## 2.0000   multiple enabled transitions:  data.training.all data.new model.selected model.final data.training.all.prediction data.new.prediction   firing:  model.selected 
## 3.0000    3   0 2 1 0

glb_chunks_df <- myadd_chunk(glb_chunks_df, "fit.data.training", major.inc = TRUE)
##                label step_major step_minor label_minor     bgn     end
## 19        fit.models          8          3           3 377.582 380.781
## 20 fit.data.training          9          0           0 380.781      NA
##    elapsed
## 19   3.199
## 20      NA

Step 9.0: fit data training

```{r fit.data.training_0, cache=FALSE, eval=myevlChunk(glbChunks, glbOut$pfx)}

## [1] "myfit_mdl: enter: 0.000000 secs"
## [1] "myfit_mdl: fitting model: Final.All.X###glmnet"
## [1] "    indepVar: Gender.fctr,Q113181.fctr,Q120472.fctr,Q115611.fctr,Q120650.fctr,Q118237.fctr,.rnorm,Q122120.fctr,Q110740.fctr,Q122770.fctr,Q118117.fctr,Income.fctr,Q116441.fctr,Q118233.fctr,Q106272.fctr,Q119650.fctr,Q124742.fctr,Q122771.fctr,Q99480.fctr,Q116197.fctr,Q116881.fctr,Q101596.fctr,Q122769.fctr,Q108855.fctr,Q120014.fctr,Q119334.fctr,Q106993.fctr,Q107869.fctr,Q121011.fctr,Q117186.fctr,Q106997.fctr,Q108617.fctr,Q98197.fctr,Q106042.fctr,Q115777.fctr,Q123621.fctr,Q106388.fctr,Q114152.fctr,Q124122.fctr,Q120194.fctr,Q116797.fctr,Q105655.fctr,Q115899.fctr,Q116448.fctr,Q117193.fctr,Q108754.fctr,Q108856.fctr,YOB.Age.fctr,Q123464.fctr,Q99581.fctr,Q114961.fctr,Q104996.fctr,Q108343.fctr,Q120012.fctr,Q120978.fctr,Q98578.fctr,Q103293.fctr,Q106389.fctr,Q98869.fctr,Q112512.fctr,Q116953.fctr,Q100010.fctr,Q111220.fctr,Q102906.fctr,Q121700.fctr,Q112478.fctr,Q115610.fctr,Q119851.fctr,Q114517.fctr,Q118892.fctr,Q115602.fctr,Q120379.fctr,Q107491.fctr,Q114748.fctr,Q99982.fctr,Q113992.fctr,Q115390.fctr,Q118232.fctr,Q96024.fctr,Q115195.fctr,Q121699.fctr,Q100680.fctr,Q111580.fctr,Q102289.fctr,Q102687.fctr,Q105840.fctr,Q101162.fctr,Q108950.fctr,Q116601.fctr,Q108342.fctr,Q100562.fctr,Q113584.fctr,Q109367.fctr,Q99716.fctr,Hhold.fctr,Q112270.fctr,Q98059.fctr,Q111848.fctr,Q102674.fctr,Q114386.fctr,Q98078.fctr,Q102089.fctr,Edn.fctr,Q100689.fctr,Q113583.fctr,Q101163.fctr,YOB.Age.fctr:YOB.Age.dff,Q109244.fctr:.clusterid.fctr"
## [1] "myfit_mdl: setup complete: 0.693000 secs"
## Fitting alpha = 0.1, lambda = 0.0247 on full training set
## [1] "myfit_mdl: train complete: 2.546000 secs"
##   alpha     lambda
## 1   0.1 0.02469128

##             Length Class      Mode     
## a0             75  -none-     numeric  
## beta        18825  dgCMatrix  S4       
## df             75  -none-     numeric  
## dim             2  -none-     numeric  
## lambda         75  -none-     numeric  
## dev.ratio      75  -none-     numeric  
## nulldev         1  -none-     numeric  
## npasses         1  -none-     numeric  
## jerr            1  -none-     numeric  
## offset          1  -none-     logical  
## classnames      2  -none-     character
## call            5  -none-     call     
## nobs            1  -none-     numeric  
## lambdaOpt       1  -none-     numeric  
## xNames        251  -none-     character
## problemType     1  -none-     character
## tuneValue       2  data.frame list     
## obsLevels       2  -none-     character
## [1] "min lambda > lambdaOpt:"
##                     (Intercept)                          .rnorm 
##                    -0.155735522                     0.048497881 
##                      Edn.fctr.L                      Edn.fctr.Q 
##                    -0.042351538                     0.193191919 
##                      Edn.fctr.C                      Edn.fctr^4 
##                     0.033138813                     0.241901212 
##                      Edn.fctr^5                      Edn.fctr^6 
##                     0.043463735                    -0.006338041 
##                      Edn.fctr^7                    Gender.fctrF 
##                    -0.197671892                    -0.059925060 
##                    Gender.fctrM                   Hhold.fctrMKy 
##                     0.228861507                     0.061066645 
##                   Hhold.fctrPKn                   Hhold.fctrPKy 
##                    -0.285177488                     0.474419006 
##                   Hhold.fctrSKn                   Hhold.fctrSKy 
##                    -0.093339977                     0.084469892 
##                   Income.fctr.L                   Income.fctr.Q 
##                     0.004233102                     0.020221507 
##                   Income.fctr.C                   Income.fctr^4 
##                     0.246940056                     0.007269751 
##                   Income.fctr^6                  Q100010.fctrNo 
##                     0.047397894                    -0.203222287 
##                  Q100562.fctrNo                  Q100680.fctrNo 
##                     0.417843950                    -0.089933103 
##                  Q100689.fctrNo                 Q100689.fctrYes 
##                    -0.101644312                    -0.318289690 
##            Q101162.fctrOptimist           Q101162.fctrPessimist 
##                    -0.250338072                     0.052653209 
##                 Q101163.fctrDad                 Q101163.fctrMom 
##                     0.118126362                    -0.507022157 
##                  Q101596.fctrNo                 Q101596.fctrYes 
##                     0.121379410                     0.435164069 
##                 Q102089.fctrOwn                Q102089.fctrRent 
##                    -0.111784825                    -0.109419905 
##                 Q102289.fctrYes                  Q102674.fctrNo 
##                    -0.028835661                     0.135270022 
##                 Q102674.fctrYes                  Q102687.fctrNo 
##                    -0.363293688                     0.003480660 
##                 Q102687.fctrYes                  Q103293.fctrNo 
##                    -0.046717749                     0.034812752 
##                  Q104996.fctrNo                 Q105655.fctrYes 
##                     0.171833641                     0.016119524 
##                  Q105840.fctrNo                 Q105840.fctrYes 
##                     0.011438126                    -0.043312984 
##                  Q106042.fctrNo                 Q106042.fctrYes 
##                     0.061266352                     0.048655135 
##                 Q106272.fctrYes                  Q106388.fctrNo 
##                     0.084804411                     0.121996345 
##                 Q106388.fctrYes                  Q106389.fctrNo 
##                    -0.015247735                     0.259718791 
##                 Q106389.fctrYes                  Q106993.fctrNo 
##                    -0.218895766                     0.079702105 
##                 Q106993.fctrYes                  Q107491.fctrNo 
##                     0.007173634                     0.173782956 
##                 Q107491.fctrYes                 Q107869.fctrYes 
##                    -0.117444407                     0.056894720 
##           Q108342.fctrIn-person              Q108342.fctrOnline 
##                    -0.078369968                    -0.389946988 
##                  Q108343.fctrNo                  Q108617.fctrNo 
##                    -0.008904055                     0.176498467 
##              Q108855.fctrUmm...           Q108856.fctrSocialize 
##                     0.261953383                     0.425563533 
##               Q108856.fctrSpace            Q108950.fctrCautious 
##                    -0.062734745                    -0.041349491 
##       Q108950.fctrRisk-friendly                 Q109367.fctrYes 
##                    -0.404759064                    -0.169860866 
##                 Q110740.fctrMac                  Q110740.fctrPC 
##                     0.101820545                     0.178432707 
##           Q111580.fctrDemanding          Q111580.fctrSupportive 
##                     0.028590482                    -0.016548159 
##                  Q111848.fctrNo                 Q111848.fctrYes 
##                    -0.018612662                    -0.091270380 
##                  Q112270.fctrNo                 Q112270.fctrYes 
##                    -0.154941982                    -0.261261506 
##                  Q112478.fctrNo                 Q112512.fctrYes 
##                     0.227655081                     0.001232412 
##                  Q113181.fctrNo                 Q113181.fctrYes 
##                    -0.105345625                     0.441107670 
##                Q113583.fctrTalk               Q113583.fctrTunes 
##                     0.032912378                    -0.319259662 
##              Q113584.fctrPeople                 Q113992.fctrYes 
##                    -0.029603101                    -0.153342195 
##                  Q114152.fctrNo          Q114386.fctrMysterious 
##                     0.072193969                     0.068137889 
##                 Q114386.fctrTMI                  Q114517.fctrNo 
##                    -0.116335033                    -0.087448270 
##                 Q114517.fctrYes                  Q114961.fctrNo 
##                    -0.011724395                    -0.082962955 
##                 Q114961.fctrYes                  Q115195.fctrNo 
##                     0.074368142                     0.203504171 
##                 Q115195.fctrYes                  Q115390.fctrNo 
##                    -0.108531722                     0.292109514 
##                 Q115390.fctrYes                  Q115602.fctrNo 
##                    -0.054106733                    -0.020592405 
##                  Q115611.fctrNo                 Q115611.fctrYes 
##                    -0.237233630                     0.411027888 
##                 Q115777.fctrEnd               Q115777.fctrStart 
##                    -0.149096992                     0.014511518 
##                  Q115899.fctrCs                  Q115899.fctrMe 
##                    -0.123643551                     0.068877613 
##                Q116197.fctrA.M.                Q116197.fctrP.M. 
##                     0.047572789                     0.173849246 
##                  Q116441.fctrNo                 Q116441.fctrYes 
##                    -0.167402287                     0.247490339 
##                  Q116448.fctrNo                  Q116601.fctrNo 
##                     0.004771013                     0.360764668 
##                 Q116601.fctrYes                  Q116797.fctrNo 
##                    -0.193406319                     0.100975739 
##                 Q116797.fctrYes               Q116881.fctrHappy 
##                     0.026701929                    -0.056827720 
##               Q116881.fctrRight                  Q116953.fctrNo 
##                     0.080966634                    -0.048335737 
##                 Q116953.fctrYes         Q117186.fctrCool headed 
##                    -0.018545109                    -0.132569790 
##          Q117186.fctrHot headed           Q117193.fctrOdd hours 
##                     0.073624353                    -0.022905890 
##                 Q118117.fctrYes                  Q118232.fctrId 
##                     0.050181001                    -0.162544078 
##                  Q118232.fctrPr                  Q118233.fctrNo 
##                    -0.187927698                     0.111321953 
##                 Q118233.fctrYes                  Q118237.fctrNo 
##                     0.020997792                     0.055939690 
##                 Q118237.fctrYes                  Q118892.fctrNo 
##                     0.151362010                     0.064459710 
##                 Q118892.fctrYes                  Q119334.fctrNo 
##                    -0.118309250                    -0.035568239 
##                 Q119334.fctrYes           Q119650.fctrReceiving 
##                     0.055323684                     0.029184660 
##                  Q119851.fctrNo                 Q119851.fctrYes 
##                     0.223356813                    -0.093763963 
##                  Q120012.fctrNo                 Q120012.fctrYes 
##                     0.079509216                    -0.037475190 
##                  Q120014.fctrNo         Q120194.fctrStudy first 
##                    -0.062424533                    -0.174101517 
##           Q120194.fctrTry first                  Q120379.fctrNo 
##                    -0.055955869                     0.112649301 
##                 Q120379.fctrYes             Q120472.fctrScience 
##                    -0.162600689                     0.133664785 
##                  Q120650.fctrNo                 Q120650.fctrYes 
##                    -0.320628227                     0.174754865 
##                 Q120978.fctrYes                  Q121011.fctrNo 
##                    -0.032742146                     0.099002524 
##                  Q121699.fctrNo                 Q121699.fctrYes 
##                    -0.005350878                    -0.158072511 
##                 Q121700.fctrYes                  Q122120.fctrNo 
##                    -0.140472937                     0.021819384 
##                 Q122120.fctrYes                  Q122769.fctrNo 
##                     0.190361999                     0.047735034 
##                  Q122770.fctrNo                 Q122770.fctrYes 
##                    -0.121762115                     0.044963124 
##                  Q122771.fctrPc                  Q122771.fctrPt 
##                    -0.077074804                     0.210204411 
##                 Q123464.fctrYes                  Q123621.fctrNo 
##                    -0.285560018                     0.108394236 
##                  Q124122.fctrNo                 Q124122.fctrYes 
##                     0.118732992                     0.013414727 
##                  Q124742.fctrNo                 Q124742.fctrYes 
##                     0.018102582                     0.023871442 
##                   Q96024.fctrNo           Q98059.fctrOnly-child 
##                    -0.023149480                     0.473171414 
##                  Q98059.fctrYes                   Q98078.fctrNo 
##                    -0.049531068                    -0.054075183 
##                   Q98197.fctrNo                  Q98197.fctrYes 
##                    -0.499136744                     0.159643726 
##                   Q98578.fctrNo                  Q98578.fctrYes 
##                     0.165560431                     0.095720502 
##                   Q98869.fctrNo                   Q99480.fctrNo 
##                    -0.402958797                    -0.117039476 
##                  Q99480.fctrYes                   Q99581.fctrNo 
##                     0.321839509                     0.059302405 
##                  Q99581.fctrYes                   Q99716.fctrNo 
##                     0.096054707                    -0.173201515 
##                  YOB.Age.fctr.L                  YOB.Age.fctr.Q 
##                    -0.293339238                    -0.269655747 
##                  YOB.Age.fctr.C                  YOB.Age.fctr^4 
##                    -0.044817098                    -0.082642447 
##                  YOB.Age.fctr^8 Q109244.fctrNA:.clusterid.fctr1 
##                     0.086869050                     0.004750456 
## Q109244.fctrNA:.clusterid.fctr2 Q109244.fctrNA:.clusterid.fctr3 
##                    -0.112960582                     0.064150685 
## YOB.Age.fctr(15,20]:YOB.Age.dff YOB.Age.fctr(35,40]:YOB.Age.dff 
##                    -0.010906574                    -0.093751767 
## [1] "max lambda < lambdaOpt:"
##                     (Intercept)                          .rnorm 
##                   -1.621359e-01                    4.937408e-02 
##                      Edn.fctr.L                      Edn.fctr.Q 
##                   -4.113826e-02                    2.038823e-01 
##                      Edn.fctr.C                      Edn.fctr^4 
##                    4.036092e-02                    2.482406e-01 
##                      Edn.fctr^5                      Edn.fctr^6 
##                    5.311455e-02                   -8.704239e-03 
##                      Edn.fctr^7                    Gender.fctrF 
##                   -2.036835e-01                   -5.529399e-02 
##                    Gender.fctrM                   Hhold.fctrMKy 
##                    2.356193e-01                    6.362269e-02 
##                   Hhold.fctrPKn                   Hhold.fctrPKy 
##                   -2.897303e-01                    4.912855e-01 
##                   Hhold.fctrSKn                   Hhold.fctrSKy 
##                   -9.517399e-02                    9.609208e-02 
##                   Income.fctr.L                   Income.fctr.Q 
##                    6.582764e-03                    2.280676e-02 
##                   Income.fctr.C                   Income.fctr^4 
##                    2.537842e-01                    1.205964e-02 
##                   Income.fctr^6                  Q100010.fctrNo 
##                    5.114986e-02                   -2.139541e-01 
##                  Q100562.fctrNo                  Q100680.fctrNo 
##                    4.348235e-01                   -9.904885e-02 
##                  Q100689.fctrNo                 Q100689.fctrYes 
##                   -1.141361e-01                   -3.389443e-01 
##            Q101162.fctrOptimist           Q101162.fctrPessimist 
##                   -2.598687e-01                    5.567984e-02 
##                 Q101163.fctrDad                 Q101163.fctrMom 
##                    1.222992e-01                   -5.212616e-01 
##                  Q101596.fctrNo                 Q101596.fctrYes 
##                    1.384897e-01                    4.593971e-01 
##                 Q102089.fctrOwn                Q102089.fctrRent 
##                   -1.266792e-01                   -1.207326e-01 
##                 Q102289.fctrYes                  Q102674.fctrNo 
##                   -3.425080e-02                    1.401204e-01 
##                 Q102674.fctrYes                  Q102687.fctrNo 
##                   -3.724177e-01                    9.197990e-03 
##                 Q102687.fctrYes                  Q102906.fctrNo 
##                   -4.788108e-02                    2.928707e-03 
##                  Q103293.fctrNo                  Q104996.fctrNo 
##                    3.907181e-02                    1.775747e-01 
##                 Q105655.fctrYes                  Q105840.fctrNo 
##                    2.289021e-02                    8.012511e-03 
##                 Q105840.fctrYes                  Q106042.fctrNo 
##                   -4.987565e-02                    6.853146e-02 
##                 Q106042.fctrYes                 Q106272.fctrYes 
##                    5.708849e-02                    8.917524e-02 
##                  Q106388.fctrNo                 Q106388.fctrYes 
##                    1.264224e-01                   -2.151703e-02 
##                  Q106389.fctrNo                 Q106389.fctrYes 
##                    2.629391e-01                   -2.333123e-01 
##                  Q106993.fctrNo                 Q106993.fctrYes 
##                    8.885987e-02                    1.192608e-02 
##                  Q107491.fctrNo                 Q107491.fctrYes 
##                    1.754278e-01                   -1.294912e-01 
##                 Q107869.fctrYes           Q108342.fctrIn-person 
##                    6.747350e-02                   -8.892355e-02 
##              Q108342.fctrOnline                  Q108343.fctrNo 
##                   -4.099420e-01                   -7.074764e-03 
##                 Q108343.fctrYes                  Q108617.fctrNo 
##                    8.223200e-03                    1.893368e-01 
##              Q108855.fctrUmm...           Q108856.fctrSocialize 
##                    2.757209e-01                    4.454879e-01 
##               Q108856.fctrSpace            Q108950.fctrCautious 
##                   -6.649432e-02                   -5.350408e-02 
##       Q108950.fctrRisk-friendly                  Q109367.fctrNo 
##                   -4.214514e-01                   -7.038724e-03 
##                 Q109367.fctrYes                 Q110740.fctrMac 
##                   -1.759965e-01                    1.101285e-01 
##                  Q110740.fctrPC           Q111580.fctrDemanding 
##                    1.876568e-01                    3.610544e-02 
##          Q111580.fctrSupportive                  Q111848.fctrNo 
##                   -1.557874e-02                   -2.552821e-02 
##                 Q111848.fctrYes                  Q112270.fctrNo 
##                   -9.803264e-02                   -1.661432e-01 
##                 Q112270.fctrYes                  Q112478.fctrNo 
##                   -2.765758e-01                    2.378109e-01 
##                 Q112512.fctrYes                  Q113181.fctrNo 
##                    9.129838e-03                   -1.074855e-01 
##                 Q113181.fctrYes                Q113583.fctrTalk 
##                    4.501721e-01                    3.563799e-02 
##               Q113583.fctrTunes              Q113584.fctrPeople 
##                   -3.295296e-01                   -3.745099e-02 
##                 Q113992.fctrYes                  Q114152.fctrNo 
##                   -1.601692e-01                    8.020392e-02 
##                 Q114152.fctrYes          Q114386.fctrMysterious 
##                   -2.332660e-03                    7.347392e-02 
##                 Q114386.fctrTMI                  Q114517.fctrNo 
##                   -1.167745e-01                   -9.715113e-02 
##                 Q114517.fctrYes                  Q114961.fctrNo 
##                   -2.214456e-02                   -8.526873e-02 
##                 Q114961.fctrYes                  Q115195.fctrNo 
##                    8.161552e-02                    2.054169e-01 
##                 Q115195.fctrYes                  Q115390.fctrNo 
##                   -1.162603e-01                    3.000349e-01 
##                 Q115390.fctrYes                  Q115602.fctrNo 
##                   -5.505851e-02                   -2.812334e-02 
##                  Q115611.fctrNo                 Q115611.fctrYes 
##                   -2.395182e-01                    4.201866e-01 
##                 Q115777.fctrEnd               Q115777.fctrStart 
##                   -1.581595e-01                    1.412591e-02 
##                  Q115899.fctrCs                  Q115899.fctrMe 
##                   -1.303256e-01                    7.413105e-02 
##                Q116197.fctrA.M.                Q116197.fctrP.M. 
##                    6.078095e-02                    1.859349e-01 
##                  Q116441.fctrNo                 Q116441.fctrYes 
##                   -1.741618e-01                    2.498662e-01 
##                  Q116448.fctrNo                  Q116601.fctrNo 
##                    8.958500e-03                    3.607235e-01 
##                 Q116601.fctrYes                  Q116797.fctrNo 
##                   -2.047098e-01                    1.158964e-01 
##                 Q116797.fctrYes               Q116881.fctrHappy 
##                    3.980174e-02                   -5.831995e-02 
##               Q116881.fctrRight                  Q116953.fctrNo 
##                    8.390039e-02                   -6.333457e-02 
##                 Q116953.fctrYes         Q117186.fctrCool headed 
##                   -2.900009e-02                   -1.385066e-01 
##          Q117186.fctrHot headed           Q117193.fctrOdd hours 
##                    7.475897e-02                   -2.977243e-02 
##                 Q118117.fctrYes                  Q118232.fctrId 
##                    5.163478e-02                   -1.811687e-01 
##                  Q118232.fctrPr                  Q118233.fctrNo 
##                   -2.060572e-01                    1.234449e-01 
##                 Q118233.fctrYes                  Q118237.fctrNo 
##                    3.224856e-02                    6.363322e-02 
##                 Q118237.fctrYes                  Q118892.fctrNo 
##                    1.608285e-01                    6.384954e-02 
##                 Q118892.fctrYes                  Q119334.fctrNo 
##                   -1.225044e-01                   -3.780577e-02 
##                 Q119334.fctrYes           Q119650.fctrReceiving 
##                    6.013642e-02                    3.407147e-02 
##                  Q119851.fctrNo                 Q119851.fctrYes 
##                    2.301931e-01                   -9.264659e-02 
##                  Q120012.fctrNo                 Q120012.fctrYes 
##                    8.428296e-02                   -3.705426e-02 
##                  Q120014.fctrNo         Q120194.fctrStudy first 
##                   -6.439023e-02                   -1.898417e-01 
##           Q120194.fctrTry first                  Q120379.fctrNo 
##                   -6.889291e-02                    1.191147e-01 
##                 Q120379.fctrYes             Q120472.fctrScience 
##                   -1.635323e-01                    1.392245e-01 
##                  Q120650.fctrNo                 Q120650.fctrYes 
##                   -3.250471e-01                    1.841044e-01 
##                 Q120978.fctrYes                  Q121011.fctrNo 
##                   -3.529960e-02                    1.037108e-01 
##                  Q121699.fctrNo                 Q121699.fctrYes 
##                   -1.752524e-02                   -1.681560e-01 
##                 Q121700.fctrYes                  Q122120.fctrNo 
##                   -1.464318e-01                    3.043047e-02 
##                 Q122120.fctrYes                  Q122769.fctrNo 
##                    2.043593e-01                    5.248929e-02 
##                  Q122770.fctrNo                 Q122770.fctrYes 
##                   -1.267999e-01                    4.473062e-02 
##                  Q122771.fctrPc                  Q122771.fctrPt 
##                   -8.575892e-02                    2.125432e-01 
##                 Q123464.fctrYes                  Q123621.fctrNo 
##                   -2.980636e-01                    1.148735e-01 
##                  Q124122.fctrNo                 Q124122.fctrYes 
##                    1.247488e-01                    1.958395e-02 
##                  Q124742.fctrNo                 Q124742.fctrYes 
##                    1.948799e-02                    2.790232e-02 
##                   Q96024.fctrNo           Q98059.fctrOnly-child 
##                   -2.877279e-02                    4.945826e-01 
##                  Q98059.fctrYes                   Q98078.fctrNo 
##                   -5.029310e-02                   -6.253256e-02 
##                   Q98197.fctrNo                  Q98197.fctrYes 
##                   -5.132830e-01                    1.578232e-01 
##                   Q98578.fctrNo                  Q98578.fctrYes 
##                    1.783604e-01                    1.112756e-01 
##                   Q98869.fctrNo                   Q99480.fctrNo 
##                   -4.132455e-01                   -1.206124e-01 
##                  Q99480.fctrYes                   Q99581.fctrNo 
##                    3.303394e-01                    7.059475e-02 
##                  Q99581.fctrYes                   Q99716.fctrNo 
##                    1.122950e-01                   -1.848122e-01 
##                  YOB.Age.fctr.L                  YOB.Age.fctr.Q 
##                   -3.118703e-01                   -2.859581e-01 
##                  YOB.Age.fctr.C                  YOB.Age.fctr^4 
##                   -5.181447e-02                   -9.358444e-02 
##                  YOB.Age.fctr^8 Q109244.fctrNA:.clusterid.fctr1 
##                    8.623473e-02                    9.992372e-03 
## Q109244.fctrNA:.clusterid.fctr2 Q109244.fctrNA:.clusterid.fctr3 
##                   -1.220764e-01                    7.846628e-02 
## Q109244.fctrNA:.clusterid.fctr4 YOB.Age.fctr(15,20]:YOB.Age.dff 
##                   -4.937098e-04                   -1.398681e-02 
## YOB.Age.fctr(35,40]:YOB.Age.dff YOB.Age.fctr(40,50]:YOB.Age.dff 
##                   -9.675024e-02                   -3.583804e-05 
## [1] "myfit_mdl: train diagnostics complete: 2.621000 secs"

##          Prediction
## Reference   D   R
##         D 871 300
##         R 417 596
##       Accuracy          Kappa  AccuracyLower  AccuracyUpper   AccuracyNull 
##   6.717033e-01   3.347686e-01   6.515595e-01   6.913854e-01   5.361722e-01 
## AccuracyPValue  McnemarPValue 
##   4.506595e-38   1.476942e-05 
## [1] "myfit_mdl: predict complete: 8.293000 secs"
##                     id
## 1 Final.All.X###glmnet
##                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             feats
## 1 Gender.fctr,Q113181.fctr,Q120472.fctr,Q115611.fctr,Q120650.fctr,Q118237.fctr,.rnorm,Q122120.fctr,Q110740.fctr,Q122770.fctr,Q118117.fctr,Income.fctr,Q116441.fctr,Q118233.fctr,Q106272.fctr,Q119650.fctr,Q124742.fctr,Q122771.fctr,Q99480.fctr,Q116197.fctr,Q116881.fctr,Q101596.fctr,Q122769.fctr,Q108855.fctr,Q120014.fctr,Q119334.fctr,Q106993.fctr,Q107869.fctr,Q121011.fctr,Q117186.fctr,Q106997.fctr,Q108617.fctr,Q98197.fctr,Q106042.fctr,Q115777.fctr,Q123621.fctr,Q106388.fctr,Q114152.fctr,Q124122.fctr,Q120194.fctr,Q116797.fctr,Q105655.fctr,Q115899.fctr,Q116448.fctr,Q117193.fctr,Q108754.fctr,Q108856.fctr,YOB.Age.fctr,Q123464.fctr,Q99581.fctr,Q114961.fctr,Q104996.fctr,Q108343.fctr,Q120012.fctr,Q120978.fctr,Q98578.fctr,Q103293.fctr,Q106389.fctr,Q98869.fctr,Q112512.fctr,Q116953.fctr,Q100010.fctr,Q111220.fctr,Q102906.fctr,Q121700.fctr,Q112478.fctr,Q115610.fctr,Q119851.fctr,Q114517.fctr,Q118892.fctr,Q115602.fctr,Q120379.fctr,Q107491.fctr,Q114748.fctr,Q99982.fctr,Q113992.fctr,Q115390.fctr,Q118232.fctr,Q96024.fctr,Q115195.fctr,Q121699.fctr,Q100680.fctr,Q111580.fctr,Q102289.fctr,Q102687.fctr,Q105840.fctr,Q101162.fctr,Q108950.fctr,Q116601.fctr,Q108342.fctr,Q100562.fctr,Q113584.fctr,Q109367.fctr,Q99716.fctr,Hhold.fctr,Q112270.fctr,Q98059.fctr,Q111848.fctr,Q102674.fctr,Q114386.fctr,Q98078.fctr,Q102089.fctr,Edn.fctr,Q100689.fctr,Q113583.fctr,Q101163.fctr,YOB.Age.fctr:YOB.Age.dff,Q109244.fctr:.clusterid.fctr
##   max.nTuningRuns min.elapsedtime.everything min.elapsedtime.final
## 1               0                      1.761                  1.12
##   max.AUCpROC.fit max.Sens.fit max.Spec.fit max.AUCROCR.fit
## 1       0.6660801    0.7438087    0.5883514       0.7351636
##   opt.prob.threshold.fit max.f.score.fit max.Accuracy.fit
## 1                    0.5       0.6244107        0.6717033
##   max.AccuracyLower.fit max.AccuracyUpper.fit max.Kappa.fit
## 1             0.6515595             0.6913854     0.3347686
## [1] "myfit_mdl: exit: 8.316000 secs"
##                label step_major step_minor label_minor     bgn     end
## 20 fit.data.training          9          0           0 380.781 389.605
## 21 fit.data.training          9          1           1 389.605      NA
##    elapsed
## 20   8.824
## 21      NA
#stop(here"); glb2Sav()
if (glb_is_classification && glb_is_binomial) 
    prob_threshold <- glb_models_df[glb_models_df$id == glbMdlSelId,
                                        "opt.prob.threshold.OOB"] else 
    prob_threshold <- NULL

if (grepl("Ensemble", glbMdlFinId)) {
    # Get predictions for each model in ensemble; Outliers that have been moved to OOB might not have been predicted yet
    mdlEnsembleComps <- unlist(str_split(subset(glb_models_df, 
                                                id == glbMdlFinId)$feats, ","))
    if (glb_is_classification)
    #     mdlEnsembleComps <- gsub("\\.prob$", "", mdlEnsembleComps)
    # mdlEnsembleComps <- gsub(paste0("^", 
    #                     gsub(".", "\\.", mygetPredictIds(glb_rsp_var)$value, fixed = TRUE)),
    #                          "", mdlEnsembleComps)
        mdlEnsembleComps <- glb_models_df$id[sapply(glb_models_df$id, function(thsMdlId)
                        mygetPredictIds(glb_rsp_var, thsMdlId)$prob  %in% mdlEnsembleComps)] else
        mdlEnsembleComps <- glb_models_df$id[sapply(glb_models_df$id, function(thsMdlId)
                        mygetPredictIds(glb_rsp_var, thsMdlId)$value  %in% mdlEnsembleComps)]
                        
    for (mdl_id in mdlEnsembleComps) {
        glbObsTrn <- glb_get_predictions(df = glbObsTrn, mdl_id = mdl_id, 
                                            rsp_var = glb_rsp_var,
                                            prob_threshold_def = prob_threshold)
        glbObsNew <- glb_get_predictions(df = glbObsNew, mdl_id = mdl_id, 
                                            rsp_var = glb_rsp_var,
                                            prob_threshold_def = prob_threshold)
        # glb_fin_mdl uses the same coefficients as glb_sel_mdl, 
        #   so copy the "Final" columns into "non-Final" columns
        glbObsTrn[, gsub("Final.", "", unlist(mygetPredictIds(glb_rsp_var, mdl_id)))] <-
            glbObsTrn[, unlist(mygetPredictIds(glb_rsp_var, mdl_id))]
        glbObsNew[, gsub("Final.", "", unlist(mygetPredictIds(glb_rsp_var, mdl_id)))] <-
            glbObsNew[, unlist(mygetPredictIds(glb_rsp_var, mdl_id))]
    }    
}
glbObsTrn <- glb_get_predictions(df = glbObsTrn, mdl_id = glbMdlFinId, 
                                     rsp_var = glb_rsp_var,
                                    prob_threshold_def = prob_threshold)
## Warning in glb_get_predictions(df = glbObsTrn, mdl_id = glbMdlFinId,
## rsp_var = glb_rsp_var, : Using default probability threshold: 0.4
glb_featsimp_df <- myget_feats_importance(mdl=glb_fin_mdl,
                                          featsimp_df=glb_featsimp_df)
#glb_featsimp_df[, paste0(glbMdlFinId, ".imp")] <- glb_featsimp_df$imp
print(glb_featsimp_df)
##                                  All.X..rcv.glmnet.imp
## Q101163.fctrMom                            58.70889930
## Q98197.fctrNo                              65.04828571
## Hhold.fctrPKy                             100.00000000
## Q98059.fctrOnly-child                      41.81605007
## Q113181.fctrYes                            53.87955132
## Q101596.fctrYes                            48.66777819
## Q108856.fctrSocialize                      44.04979703
## Q100562.fctrNo                             56.99103709
## Q115611.fctrYes                            54.36119266
## Q108950.fctrRisk-friendly                  54.82548652
## Q98869.fctrNo                              49.75750190
## Q108342.fctrOnline                         26.51987332
## Q102674.fctrYes                            42.37404254
## Q116601.fctrNo                             48.16811052
## Q99480.fctrYes                             45.37060282
## Q100689.fctrYes                            51.33794846
## Q113583.fctrTunes                          40.14270897
## Q120650.fctrNo                             45.12703792
## YOB.Age.fctr.L                             38.50461782
## Q115390.fctrNo                             35.85133428
## Q123464.fctrYes                            58.37654216
## Hhold.fctrPKn                              15.64519624
## YOB.Age.fctr.Q                             32.72523076
## Q108855.fctrUmm...                         30.65122953
## Q112270.fctrYes                            34.69973543
## Q106389.fctrNo                             29.79700650
## Q101162.fctrOptimist                       14.79344561
## Income.fctr.C                              26.58502973
## Q116441.fctrYes                            32.56134900
## Edn.fctr^4                                 33.47414357
## Q115611.fctrNo                             26.63256892
## Gender.fctrM                               30.99175680
## Q112478.fctrNo                             37.76366344
## Q119851.fctrNo                             20.74322494
## Q106389.fctrYes                            27.24662484
## Q122771.fctrPt                             38.59326056
## Q100010.fctrNo                             29.53498245
## Q115195.fctrNo                             18.53860388
## Edn.fctr^7                                 13.33454917
## Q116601.fctrYes                            19.11653953
## Edn.fctr.Q                                 24.48897959
## Q122120.fctrYes                            25.14327685
## Q118232.fctrPr                             23.05912330
## Q110740.fctrPC                             29.99555729
## Q108617.fctrNo                             24.86148060
## Q120194.fctrStudy first                    25.25057298
## Q120650.fctrYes                            15.29265166
## Q116197.fctrP.M.                           21.74573471
## Q99716.fctrNo                              23.15453176
## Q107491.fctrNo                             15.26966483
## Q104996.fctrNo                             25.76255553
## Q109367.fctrYes                            17.30956652
## Q116441.fctrNo                             31.96112168
## Q98578.fctrNo                              20.02779169
## Q118232.fctrId                             12.82468958
## Q120379.fctrYes                            33.89015581
## Q121699.fctrYes                            14.69471751
## Q98197.fctrYes                             23.92002846
## Q112270.fctrNo                             10.16978124
## Q113992.fctrYes                             5.76189801
## Q118237.fctrYes                             0.00000000
## Q115777.fctrEnd                            19.74269986
## Q121700.fctrYes                            16.10352224
## Q102674.fctrNo                             18.68634335
## Q120472.fctrScience                        18.46387937
## Q117186.fctrCool headed                    18.79970907
## Q101596.fctrNo                             12.59209022
## Q115899.fctrCs                             29.83100896
## Q106388.fctrNo                             28.71415220
## Q122770.fctrNo                              7.53984667
## Q107491.fctrYes                            25.10716089
## Q124122.fctrNo                              7.97783846
## Q118892.fctrYes                            16.65291627
## Q101163.fctrDad                            13.87998117
## Q99480.fctrNo                              19.02748347
## Q114386.fctrTMI                            12.09039160
## Q102089.fctrOwn                            25.19677217
## Q109244.fctrNA:.clusterid.fctr2             2.09361358
## Q118233.fctrNo                              9.98753273
## Q120379.fctrNo                             11.45508668
## Q102089.fctrRent                           34.32823140
## Q115195.fctrYes                            25.00880052
## Q123621.fctrNo                             13.99411708
## Q113181.fctrNo                             10.21655090
## Q100689.fctrNo                              7.40909895
## Q116797.fctrNo                             24.84439074
## Q110740.fctrMac                            20.43226420
## Q121011.fctrNo                             14.27787962
## Q99581.fctrYes                              7.63612487
## Q98578.fctrYes                             22.69548452
## YOB.Age.fctr(35,40]:YOB.Age.dff             6.71908081
## Hhold.fctrSKn                              12.58809153
## Q119851.fctrYes                             7.49822551
## Q111848.fctrYes                             8.04210993
## Q100680.fctrNo                             21.32491293
## Q114517.fctrNo                             11.12476612
## Hhold.fctrSKy                               0.00000000
## YOB.Age.fctr^8                             10.19324341
## Q106272.fctrYes                            12.09566958
## YOB.Age.fctr^4                              7.32963244
## Q114961.fctrNo                              5.64204447
## Q106993.fctrNo                             12.46648755
## Q116881.fctrRight                          11.31786995
## Q108342.fctrIn-person                       9.87207559
## Q120012.fctrNo                             13.53443016
## Q122771.fctrPc                              2.84528130
## Q114961.fctrYes                            16.79250041
## Q114152.fctrNo                              0.00000000
## Q117186.fctrHot headed                     11.14929669
## Q115899.fctrMe                              6.43902811
## Q114386.fctrMysterious                     19.45040116
## Q109244.fctrNA:.clusterid.fctr3             7.40697169
## Q118892.fctrNo                              3.16183870
## Q108856.fctrSpace                          10.95016791
## Q106042.fctrNo                             14.31677466
## Q120014.fctrNo                             18.25595493
## Q99581.fctrNo                               0.00000000
## Hhold.fctrMKy                              14.86167522
## Q107869.fctrYes                             6.34735376
## Q120194.fctrTry first                       0.00000000
## Gender.fctrF                                6.85183036
## Q118237.fctrNo                              2.91954724
## Q116881.fctrHappy                           0.00000000
## Q119334.fctrYes                             8.31937455
## Q98078.fctrNo                               3.22890502
## Q115390.fctrYes                             0.00000000
## Q101162.fctrPessimist                      30.46431892
## Q116953.fctrNo                             12.04415904
## Q116197.fctrA.M.                            0.47480200
## Q106042.fctrYes                             5.86829658
## Q118117.fctrYes                            16.71307330
## Q98059.fctrYes                              6.35401501
## Q122769.fctrNo                              0.00000000
## .rnorm                                      1.31590903
## Income.fctr^6                              12.20797580
## Q102687.fctrYes                             9.10956985
## YOB.Age.fctr.C                             13.67668034
## Edn.fctr^5                                 17.18869620
## Q122770.fctrYes                             0.00000000
## Q105840.fctrYes                             0.00000000
## Q108950.fctrCautious                        2.44007671
## Edn.fctr.L                                  4.93985986
## Q120012.fctrYes                             0.00000000
## Q119334.fctrNo                              5.77603390
## Q103293.fctrNo                              9.13975875
## Edn.fctr.C                                  7.94753921
## Q113583.fctrTalk                            0.00000000
## Q120978.fctrYes                            15.30358299
## Q113584.fctrPeople                          6.97987555
## Q111580.fctrDemanding                       0.00000000
## Q119650.fctrReceiving                       8.14856004
## Q102289.fctrYes                            17.16212334
## Q116797.fctrYes                            11.90204138
## Q124742.fctrYes                             8.43567189
## Q117193.fctrOdd hours                       0.97986083
## Q96024.fctrNo                               4.51911502
## Q122120.fctrNo                              0.00000000
## Q118233.fctrYes                             0.00000000
## Q115602.fctrNo                              7.49895999
## Q116953.fctrYes                            16.38551337
## Income.fctr.Q                               5.01776984
## Q111848.fctrNo                             20.14164588
## Q124742.fctrNo                              0.00000000
## Q105655.fctrYes                             0.00000000
## Q106388.fctrYes                            19.44404023
## Q111580.fctrSupportive                      3.08478749
## Q124122.fctrYes                             2.30458741
## Q115777.fctrStart                          11.56229740
## Q114517.fctrYes                             0.00000000
## YOB.Age.fctr(15,20]:YOB.Age.dff             1.47081274
## Q105840.fctrNo                              6.75070028
## Q108343.fctrNo                              0.00000000
## Income.fctr^4                              19.96596182
## Q106993.fctrYes                             0.00000000
## Q121699.fctrNo                              8.90787235
## Edn.fctr^6                                 14.02376046
## Q109244.fctrNA:.clusterid.fctr1             0.00000000
## Q116448.fctrNo                             17.38150488
## Q102687.fctrNo                              6.38732137
## Income.fctr.L                               0.00000000
## Q112512.fctrYes                             1.54061708
## Q108343.fctrYes                             5.38349362
## Q109367.fctrNo                             30.76271919
## Q102906.fctrNo                              0.00000000
## Q114152.fctrYes                             2.97986267
## Q109244.fctrNA:.clusterid.fctr4             0.00000000
## YOB.Age.fctr(40,50]:YOB.Age.dff             0.00000000
## Hhold.fctrMKn                               3.96941185
## Income.fctr^5                               0.00000000
## Q100010.fctrYes                             0.00000000
## Q100562.fctrYes                             0.00000000
## Q100680.fctrYes                             0.00000000
## Q102289.fctrNo                              0.01831279
## Q102906.fctrYes                             5.47225482
## Q103293.fctrYes                             0.00000000
## Q104996.fctrYes                             9.06503107
## Q105655.fctrNo                              0.00000000
## Q106272.fctrNo                             16.77475600
## Q106997.fctrGr                              2.91187343
## Q106997.fctrYy                              0.00000000
## Q107869.fctrNo                              0.00000000
## Q108617.fctrYes                             0.00000000
## Q108754.fctrNo                              0.00000000
## Q108754.fctrYes                             0.00000000
## Q108855.fctrYes!                            0.00000000
## Q109244.fctrNo:.clusterid.fctr1             0.00000000
## Q109244.fctrNo:.clusterid.fctr2             0.00000000
## Q109244.fctrNo:.clusterid.fctr3             0.00000000
## Q109244.fctrNo:.clusterid.fctr4             0.00000000
## Q109244.fctrYes:.clusterid.fctr1            0.00000000
## Q109244.fctrYes:.clusterid.fctr2            0.00000000
## Q109244.fctrYes:.clusterid.fctr3            0.00000000
## Q109244.fctrYes:.clusterid.fctr4            0.00000000
## Q111220.fctrNo                              0.00000000
## Q111220.fctrYes                             0.00000000
## Q112478.fctrYes                             0.00000000
## Q112512.fctrNo                             24.13237615
## Q113584.fctrTechnology                      0.00000000
## Q113992.fctrNo                              0.12317152
## Q114748.fctrNo                              4.44030358
## Q114748.fctrYes                             0.00000000
## Q115602.fctrYes                             0.00000000
## Q115610.fctrNo                             21.26751769
## Q115610.fctrYes                             1.87689570
## Q116448.fctrYes                             3.16653709
## Q117193.fctrStandard hours                  2.69447397
## Q118117.fctrNo                              0.00000000
## Q119650.fctrGiving                          7.93463365
## Q120014.fctrYes                             5.26971744
## Q120472.fctrArt                             0.00000000
## Q120978.fctrNo                              0.00000000
## Q121011.fctrYes                             0.00000000
## Q121700.fctrNo                              1.26704991
## Q122769.fctrYes                             0.00000000
## Q123464.fctrNo                              0.00000000
## Q123621.fctrYes                             0.00000000
## Q96024.fctrYes                             10.51724456
## Q98078.fctrYes                              0.00000000
## Q98869.fctrYes                              0.83171509
## Q99716.fctrYes                              0.00000000
## Q99982.fctrCheck!                           9.99813228
## Q99982.fctrNope                             0.00000000
## YOB.Age.fctr(20,25]:YOB.Age.dff             4.78865841
## YOB.Age.fctr(25,30]:YOB.Age.dff             0.00000000
## YOB.Age.fctr(30,35]:YOB.Age.dff             0.26203741
## YOB.Age.fctr(50,65]:YOB.Age.dff             0.22402287
## YOB.Age.fctr(65,90]:YOB.Age.dff             0.00000000
## YOB.Age.fctrNA:YOB.Age.dff                  0.00000000
## YOB.Age.fctr^5                              3.32559612
## YOB.Age.fctr^6                              0.00000000
## YOB.Age.fctr^7                             15.50614515
##                                  Final.All.X...glmnet.imp          imp
## Q101163.fctrMom                              1.000000e+02 1.000000e+02
## Q98197.fctrNo                                9.845073e+01 9.845073e+01
## Hhold.fctrPKy                                9.373465e+01 9.373465e+01
## Q98059.fctrOnly-child                        9.370186e+01 9.370186e+01
## Q113181.fctrYes                              8.684490e+01 8.684490e+01
## Q101596.fctrYes                              8.638678e+01 8.638678e+01
## Q108856.fctrSocialize                        8.430518e+01 8.430518e+01
## Q100562.fctrNo                               8.265561e+01 8.265561e+01
## Q115611.fctrYes                              8.095599e+01 8.095599e+01
## Q108950.fctrRisk-friendly                    8.007861e+01 8.007861e+01
## Q98869.fctrNo                                7.942760e+01 7.942760e+01
## Q108342.fctrOnline                           7.733040e+01 7.733040e+01
## Q102674.fctrYes                              7.160218e+01 7.160218e+01
## Q116601.fctrNo                               7.067989e+01 7.067989e+01
## Q99480.fctrYes                               6.345133e+01 6.345133e+01
## Q100689.fctrYes                              6.332185e+01 6.332185e+01
## Q113583.fctrTunes                            6.302831e+01 6.302831e+01
## Q120650.fctrNo                               6.302397e+01 6.302397e+01
## YOB.Age.fctr.L                               5.833462e+01 5.833462e+01
## Q115390.fctrNo                               5.759981e+01 5.759981e+01
## Q123464.fctrYes                              5.652981e+01 5.652981e+01
## Hhold.fctrPKn                                5.608462e+01 5.608462e+01
## YOB.Age.fctr.Q                               5.359071e+01 5.359071e+01
## Q108855.fctrUmm...                           5.196360e+01 5.196360e+01
## Q112270.fctrYes                              5.190008e+01 5.190008e+01
## Q106389.fctrNo                               5.103464e+01 5.103464e+01
## Q101162.fctrOptimist                         4.949061e+01 4.949061e+01
## Income.fctr.C                                4.869976e+01 4.869976e+01
## Q116441.fctrYes                              4.859949e+01 4.859949e+01
## Edn.fctr^4                                   4.768903e+01 4.768903e+01
## Q115611.fctrNo                               4.658572e+01 4.658572e+01
## Gender.fctrM                                 4.515375e+01 4.515375e+01
## Q112478.fctrNo                               4.507562e+01 4.507562e+01
## Q119851.fctrNo                               4.407891e+01 4.407891e+01
## Q106389.fctrYes                              4.355789e+01 4.355789e+01
## Q122771.fctrPt                               4.129262e+01 4.129262e+01
## Q100010.fctrNo                               4.031552e+01 4.031552e+01
## Q115195.fctrNo                               3.996006e+01 3.996006e+01
## Edn.fctr^7                                   3.900826e+01 3.900826e+01
## Q116601.fctrYes                              3.841897e+01 3.841897e+01
## Edn.fctr.Q                                   3.834841e+01 3.834841e+01
## Q122120.fctrYes                              3.794797e+01 3.794797e+01
## Q118232.fctrPr                               3.766346e+01 3.766346e+01
## Q110740.fctrPC                               3.538847e+01 3.538847e+01
## Q108617.fctrNo                               3.517782e+01 3.517782e+01
## Q120194.fctrStudy first                      3.484334e+01 3.484334e+01
## Q120650.fctrYes                              3.467375e+01 3.467375e+01
## Q116197.fctrP.M.                             3.462373e+01 3.462373e+01
## Q99716.fctrNo                                3.447471e+01 3.447471e+01
## Q107491.fctrNo                               3.412454e+01 3.412454e+01
## Q104996.fctrNo                               3.393338e+01 3.393338e+01
## Q109367.fctrYes                              3.356524e+01 3.356524e+01
## Q116441.fctrNo                               3.311260e+01 3.311260e+01
## Q98578.fctrNo                                3.303303e+01 3.303303e+01
## Q118232.fctrId                               3.271330e+01 3.271330e+01
## Q120379.fctrYes                              3.190047e+01 3.190047e+01
## Q121699.fctrYes                              3.143948e+01 3.143948e+01
## Q98197.fctrYes                               3.119298e+01 3.119298e+01
## Q112270.fctrNo                               3.087819e+01 3.087819e+01
## Q113992.fctrYes                              3.036106e+01 3.036106e+01
## Q118237.fctrYes                              3.009601e+01 3.009601e+01
## Q115777.fctrEnd                              2.963343e+01 2.963343e+01
## Q121700.fctrYes                              2.779926e+01 2.779926e+01
## Q102674.fctrNo                               2.672827e+01 2.672827e+01
## Q120472.fctrScience                          2.644680e+01 2.644680e+01
## Q117186.fctrCool headed                      2.624983e+01 2.624983e+01
## Q101596.fctrNo                               2.457771e+01 2.457771e+01
## Q115899.fctrCs                               2.453569e+01 2.453569e+01
## Q106388.fctrNo                               2.410791e+01 2.410791e+01
## Q122770.fctrNo                               2.409050e+01 2.409050e+01
## Q107491.fctrYes                              2.357096e+01 2.357096e+01
## Q124122.fctrNo                               2.354257e+01 2.354257e+01
## Q118892.fctrYes                              2.337477e+01 2.337477e+01
## Q101163.fctrDad                              2.333790e+01 2.333790e+01
## Q99480.fctrNo                                2.309701e+01 2.309701e+01
## Q114386.fctrTMI                              2.281308e+01 2.281308e+01
## Q102089.fctrOwn                              2.259473e+01 2.259473e+01
## Q109244.fctrNA:.clusterid.fctr2              2.255599e+01 2.255599e+01
## Q118233.fctrNo                               2.237498e+01 2.237498e+01
## Q120379.fctrNo                               2.237158e+01 2.237158e+01
## Q102089.fctrRent                             2.196460e+01 2.196460e+01
## Q115195.fctrYes                              2.162368e+01 2.162368e+01
## Q123621.fctrNo                               2.153856e+01 2.153856e+01
## Q113181.fctrNo                               2.073920e+01 2.073920e+01
## Q100689.fctrNo                               2.049609e+01 2.049609e+01
## Q116797.fctrNo                               2.047821e+01 2.047821e+01
## Q110740.fctrMac                              2.033579e+01 2.033579e+01
## Q121011.fctrNo                               1.961604e+01 1.961604e+01
## Q99581.fctrYes                               1.957552e+01 1.957552e+01
## Q98578.fctrYes                               1.947814e+01 1.947814e+01
## YOB.Age.fctr(35,40]:YOB.Age.dff              1.850769e+01 1.850769e+01
## Hhold.fctrSKn                                1.837278e+01 1.837278e+01
## Q119851.fctrYes                              1.831841e+01 1.831841e+01
## Q111848.fctrYes                              1.819680e+01 1.819680e+01
## Q100680.fctrNo                               1.804439e+01 1.804439e+01
## Q114517.fctrNo                               1.758490e+01 1.758490e+01
## Hhold.fctrSKy                                1.709075e+01 1.709075e+01
## YOB.Age.fctr^8                               1.699004e+01 1.699004e+01
## Q106272.fctrYes                              1.681861e+01 1.681861e+01
## YOB.Age.fctr^4                               1.670103e+01 1.670103e+01
## Q114961.fctrNo                               1.636166e+01 1.636166e+01
## Q106993.fctrNo                               1.604187e+01 1.604187e+01
## Q116881.fctrRight                            1.599978e+01 1.599978e+01
## Q108342.fctrIn-person                        1.584587e+01 1.584587e+01
## Q120012.fctrNo                               1.579992e+01 1.579992e+01
## Q122771.fctrPc                               1.550507e+01 1.550507e+01
## Q114961.fctrYes                              1.490786e+01 1.490786e+01
## Q114152.fctrNo                               1.451741e+01 1.451741e+01
## Q117186.fctrHot headed                       1.447748e+01 1.447748e+01
## Q115899.fctrMe                               1.373929e+01 1.373929e+01
## Q114386.fctrMysterious                       1.359821e+01 1.359821e+01
## Q109244.fctrNA:.clusterid.fctr3              1.323519e+01 1.323519e+01
## Q118892.fctrNo                               1.260067e+01 1.260067e+01
## Q108856.fctrSpace                            1.246620e+01 1.246620e+01
## Q106042.fctrNo                               1.234176e+01 1.234176e+01
## Q120014.fctrNo                               1.232189e+01 1.232189e+01
## Q99581.fctrNo                                1.214452e+01 1.214452e+01
## Hhold.fctrMKy                                1.208334e+01 1.208334e+01
## Q107869.fctrYes                              1.163957e+01 1.163957e+01
## Q120194.fctrTry first                        1.156545e+01 1.156545e+01
## Gender.fctrF                                 1.152499e+01 1.152499e+01
## Q118237.fctrNo                               1.131810e+01 1.131810e+01
## Q116881.fctrHappy                            1.120330e+01 1.120330e+01
## Q119334.fctrYes                              1.106326e+01 1.106326e+01
## Q98078.fctrNo                                1.098837e+01 1.098837e+01
## Q115390.fctrYes                              1.064503e+01 1.064503e+01
## Q101162.fctrPessimist                        1.045688e+01 1.045688e+01
## Q116953.fctrNo                               1.016851e+01 1.016851e+01
## Q116197.fctrA.M.                             9.935640e+00 9.935640e+00
## Q106042.fctrYes                              9.925344e+00 9.925344e+00
## Q118117.fctrYes                              9.899272e+00 9.899272e+00
## Q98059.fctrYes                               9.739722e+00 9.739722e+00
## Q122769.fctrNo                               9.573748e+00 9.573748e+00
## .rnorm                                       9.542615e+00 9.542615e+00
## Income.fctr^6                                9.461021e+00 9.461021e+00
## Q102687.fctrYes                              9.207218e+00 9.207218e+00
## YOB.Age.fctr.C                               9.106516e+00 9.106516e+00
## Edn.fctr^5                                   8.964927e+00 8.964927e+00
## Q122770.fctrYes                              8.798447e+00 8.798447e+00
## Q105840.fctrYes                              8.791584e+00 8.791584e+00
## Q108950.fctrCautious                         8.667295e+00 8.667295e+00
## Edn.fctr.L                                   8.241107e+00 8.241107e+00
## Q120012.fctrYes                              7.322620e+00 7.322620e+00
## Q119334.fctrNo                               7.072805e+00 7.072805e+00
## Q103293.fctrNo                               7.018926e+00 7.018926e+00
## Edn.fctr.C                                   6.828947e+00 6.828947e+00
## Q113583.fctrTalk                             6.575192e+00 6.575192e+00
## Q120978.fctrYes                              6.534009e+00 6.534009e+00
## Q113584.fctrPeople                           6.165363e+00 6.165363e+00
## Q111580.fctrDemanding                        5.951465e+00 5.951465e+00
## Q119650.fctrReceiving                        5.945490e+00 5.945490e+00
## Q102289.fctrYes                              5.901717e+00 5.901717e+00
## Q116797.fctrYes                              5.841529e+00 5.841529e+00
## Q124742.fctrYes                              4.864655e+00 4.864655e+00
## Q117193.fctrOdd hours                        4.807532e+00 4.807532e+00
## Q96024.fctrNo                                4.797362e+00 4.797362e+00
## Q122120.fctrNo                               4.675901e+00 4.675901e+00
## Q118233.fctrYes                              4.637856e+00 4.637856e+00
## Q115602.fctrNo                               4.385208e+00 4.385208e+00
## Q116953.fctrYes                              4.120263e+00 4.120263e+00
## Income.fctr.Q                                4.082232e+00 4.082232e+00
## Q111848.fctrNo                               3.968675e+00 3.968675e+00
## Q124742.fctrNo                               3.611213e+00 3.611213e+00
## Q105655.fctrYes                              3.473468e+00 3.473468e+00
## Q106388.fctrYes                              3.279316e+00 3.279316e+00
## Q111580.fctrSupportive                       3.197008e+00 3.197008e+00
## Q124122.fctrYes                              2.915530e+00 2.915530e+00
## Q115777.fctrStart                            2.825172e+00 2.825172e+00
## Q114517.fctrYes                              2.782313e+00 2.782313e+00
## YOB.Age.fctr(15,20]:YOB.Age.dff              2.280279e+00 2.280279e+00
## Q105840.fctrNo                               2.081460e+00 2.081460e+00
## Q108343.fctrNo                               1.659316e+00 1.659316e+00
## Income.fctr^4                                1.647360e+00 1.647360e+00
## Q106993.fctrYes                              1.626785e+00 1.626785e+00
## Q121699.fctrNo                               1.615288e+00 1.615288e+00
## Edn.fctr^6                                   1.351951e+00 1.351951e+00
## Q109244.fctrNA:.clusterid.fctr1              1.174824e+00 1.174824e+00
## Q116448.fctrNo                               1.129749e+00 1.129749e+00
## Q102687.fctrNo                               9.481816e-01 9.481816e-01
## Income.fctr.L                                9.387771e-01 9.387771e-01
## Q112512.fctrYes                              6.092220e-01 6.092220e-01
## Q108343.fctrYes                              3.829357e-01 3.829357e-01
## Q109367.fctrNo                               3.277773e-01 3.277773e-01
## Q102906.fctrNo                               1.363832e-01 1.363832e-01
## Q114152.fctrYes                              1.086266e-01 1.086266e-01
## Q109244.fctrNA:.clusterid.fctr4              2.299094e-02 2.299094e-02
## YOB.Age.fctr(40,50]:YOB.Age.dff              1.668896e-03 1.668896e-03
## Hhold.fctrMKn                                0.000000e+00 0.000000e+00
## Income.fctr^5                                0.000000e+00 0.000000e+00
## Q100010.fctrYes                              0.000000e+00 0.000000e+00
## Q100562.fctrYes                              0.000000e+00 0.000000e+00
## Q100680.fctrYes                              0.000000e+00 0.000000e+00
## Q102289.fctrNo                               0.000000e+00 0.000000e+00
## Q102906.fctrYes                              0.000000e+00 0.000000e+00
## Q103293.fctrYes                              0.000000e+00 0.000000e+00
## Q104996.fctrYes                              0.000000e+00 0.000000e+00
## Q105655.fctrNo                               0.000000e+00 0.000000e+00
## Q106272.fctrNo                               0.000000e+00 0.000000e+00
## Q106997.fctrGr                               0.000000e+00 0.000000e+00
## Q106997.fctrYy                               0.000000e+00 0.000000e+00
## Q107869.fctrNo                               0.000000e+00 0.000000e+00
## Q108617.fctrYes                              0.000000e+00 0.000000e+00
## Q108754.fctrNo                               0.000000e+00 0.000000e+00
## Q108754.fctrYes                              0.000000e+00 0.000000e+00
## Q108855.fctrYes!                             0.000000e+00 0.000000e+00
## Q109244.fctrNo:.clusterid.fctr1              0.000000e+00 0.000000e+00
## Q109244.fctrNo:.clusterid.fctr2              0.000000e+00 0.000000e+00
## Q109244.fctrNo:.clusterid.fctr3              0.000000e+00 0.000000e+00
## Q109244.fctrNo:.clusterid.fctr4              0.000000e+00 0.000000e+00
## Q109244.fctrYes:.clusterid.fctr1             0.000000e+00 0.000000e+00
## Q109244.fctrYes:.clusterid.fctr2             0.000000e+00 0.000000e+00
## Q109244.fctrYes:.clusterid.fctr3             0.000000e+00 0.000000e+00
## Q109244.fctrYes:.clusterid.fctr4             0.000000e+00 0.000000e+00
## Q111220.fctrNo                               0.000000e+00 0.000000e+00
## Q111220.fctrYes                              0.000000e+00 0.000000e+00
## Q112478.fctrYes                              0.000000e+00 0.000000e+00
## Q112512.fctrNo                               0.000000e+00 0.000000e+00
## Q113584.fctrTechnology                       0.000000e+00 0.000000e+00
## Q113992.fctrNo                               0.000000e+00 0.000000e+00
## Q114748.fctrNo                               0.000000e+00 0.000000e+00
## Q114748.fctrYes                              0.000000e+00 0.000000e+00
## Q115602.fctrYes                              0.000000e+00 0.000000e+00
## Q115610.fctrNo                               0.000000e+00 0.000000e+00
## Q115610.fctrYes                              0.000000e+00 0.000000e+00
## Q116448.fctrYes                              0.000000e+00 0.000000e+00
## Q117193.fctrStandard hours                   0.000000e+00 0.000000e+00
## Q118117.fctrNo                               0.000000e+00 0.000000e+00
## Q119650.fctrGiving                           0.000000e+00 0.000000e+00
## Q120014.fctrYes                              0.000000e+00 0.000000e+00
## Q120472.fctrArt                              0.000000e+00 0.000000e+00
## Q120978.fctrNo                               0.000000e+00 0.000000e+00
## Q121011.fctrYes                              0.000000e+00 0.000000e+00
## Q121700.fctrNo                               0.000000e+00 0.000000e+00
## Q122769.fctrYes                              0.000000e+00 0.000000e+00
## Q123464.fctrNo                               0.000000e+00 0.000000e+00
## Q123621.fctrYes                              0.000000e+00 0.000000e+00
## Q96024.fctrYes                               0.000000e+00 0.000000e+00
## Q98078.fctrYes                               0.000000e+00 0.000000e+00
## Q98869.fctrYes                               0.000000e+00 0.000000e+00
## Q99716.fctrYes                               0.000000e+00 0.000000e+00
## Q99982.fctrCheck!                            0.000000e+00 0.000000e+00
## Q99982.fctrNope                              0.000000e+00 0.000000e+00
## YOB.Age.fctr(20,25]:YOB.Age.dff              0.000000e+00 0.000000e+00
## YOB.Age.fctr(25,30]:YOB.Age.dff              0.000000e+00 0.000000e+00
## YOB.Age.fctr(30,35]:YOB.Age.dff              0.000000e+00 0.000000e+00
## YOB.Age.fctr(50,65]:YOB.Age.dff              0.000000e+00 0.000000e+00
## YOB.Age.fctr(65,90]:YOB.Age.dff              0.000000e+00 0.000000e+00
## YOB.Age.fctrNA:YOB.Age.dff                   0.000000e+00 0.000000e+00
## YOB.Age.fctr^5                               0.000000e+00 0.000000e+00
## YOB.Age.fctr^6                               0.000000e+00 0.000000e+00
## YOB.Age.fctr^7                               0.000000e+00 0.000000e+00
if (glb_is_classification && glb_is_binomial)
    glb_analytics_diag_plots(obs_df=glbObsTrn, mdl_id=glbMdlFinId, 
            prob_threshold=glb_models_df[glb_models_df$id == glbMdlSelId, 
                                         "opt.prob.threshold.OOB"]) else
    glb_analytics_diag_plots(obs_df=glbObsTrn, mdl_id=glbMdlFinId)                  
## Warning in glb_analytics_diag_plots(obs_df = glbObsTrn, mdl_id =
## glbMdlFinId, : Limiting important feature scatter plots to 5 out of 108

## [1] "Min/Max Boundaries: "
## [1] "Inaccurate: "
##   USER_ID Party.fctr Party.fctr.All.X..rcv.glmnet.prob
## 1    1264          R                        0.05188727
## 2    4660          R                        0.08817815
## 3    1461          R                        0.09734940
## 4    5551          R                        0.08817253
## 5    3380          R                        0.16232428
## 6    2591          R                        0.13902421
##   Party.fctr.All.X..rcv.glmnet Party.fctr.All.X..rcv.glmnet.err
## 1                            D                             TRUE
## 2                            D                             TRUE
## 3                            D                             TRUE
## 4                            D                             TRUE
## 5                            D                             TRUE
## 6                            D                             TRUE
##   Party.fctr.All.X..rcv.glmnet.err.abs Party.fctr.All.X..rcv.glmnet.is.acc
## 1                            0.9481127                               FALSE
## 2                            0.9118219                               FALSE
## 3                            0.9026506                               FALSE
## 4                            0.9118275                               FALSE
## 5                            0.8376757                               FALSE
## 6                            0.8609758                               FALSE
##   Party.fctr.Final.All.X...glmnet.prob Party.fctr.Final.All.X...glmnet
## 1                           0.06870115                               D
## 2                           0.07837419                               D
## 3                           0.08082581                               D
## 4                           0.11546521                               D
## 5                           0.12140736                               D
## 6                           0.15882397                               D
##   Party.fctr.Final.All.X...glmnet.err
## 1                                TRUE
## 2                                TRUE
## 3                                TRUE
## 4                                TRUE
## 5                                TRUE
## 6                                TRUE
##   Party.fctr.Final.All.X...glmnet.err.abs
## 1                               0.9312988
## 2                               0.9216258
## 3                               0.9191742
## 4                               0.8845348
## 5                               0.8785926
## 6                               0.8411760
##   Party.fctr.Final.All.X...glmnet.is.acc
## 1                                  FALSE
## 2                                  FALSE
## 3                                  FALSE
## 4                                  FALSE
## 5                                  FALSE
## 6                                  FALSE
##   Party.fctr.Final.All.X...glmnet.accurate
## 1                                    FALSE
## 2                                    FALSE
## 3                                    FALSE
## 4                                    FALSE
## 5                                    FALSE
## 6                                    FALSE
##   Party.fctr.Final.All.X...glmnet.error
## 1                            -0.3312988
## 2                            -0.3216258
## 3                            -0.3191742
## 4                            -0.2845348
## 5                            -0.2785926
## 6                            -0.2411760
##     USER_ID Party.fctr Party.fctr.All.X..rcv.glmnet.prob
## 76     6839          R                         0.2917948
## 461     305          D                                NA
## 541    6823          D                                NA
## 608    2822          D                                NA
## 649    6737          D                         0.6018561
## 787    2495          D                         0.7964733
##     Party.fctr.All.X..rcv.glmnet Party.fctr.All.X..rcv.glmnet.err
## 76                             D                             TRUE
## 461                         <NA>                               NA
## 541                         <NA>                               NA
## 608                         <NA>                               NA
## 649                            R                             TRUE
## 787                            R                             TRUE
##     Party.fctr.All.X..rcv.glmnet.err.abs
## 76                             0.7082052
## 461                                   NA
## 541                                   NA
## 608                                   NA
## 649                            0.6018561
## 787                            0.7964733
##     Party.fctr.All.X..rcv.glmnet.is.acc
## 76                                FALSE
## 461                                  NA
## 541                                  NA
## 608                                  NA
## 649                               FALSE
## 787                               FALSE
##     Party.fctr.Final.All.X...glmnet.prob Party.fctr.Final.All.X...glmnet
## 76                             0.3245193                               D
## 461                            0.4899776                               R
## 541                            0.5178457                               R
## 608                            0.5485639                               R
## 649                            0.5780908                               R
## 787                            0.7763096                               R
##     Party.fctr.Final.All.X...glmnet.err
## 76                                 TRUE
## 461                                TRUE
## 541                                TRUE
## 608                                TRUE
## 649                                TRUE
## 787                                TRUE
##     Party.fctr.Final.All.X...glmnet.err.abs
## 76                                0.6754807
## 461                               0.4899776
## 541                               0.5178457
## 608                               0.5485639
## 649                               0.5780908
## 787                               0.7763096
##     Party.fctr.Final.All.X...glmnet.is.acc
## 76                                   FALSE
## 461                                  FALSE
## 541                                  FALSE
## 608                                  FALSE
## 649                                  FALSE
## 787                                  FALSE
##     Party.fctr.Final.All.X...glmnet.accurate
## 76                                     FALSE
## 461                                    FALSE
## 541                                    FALSE
## 608                                    FALSE
## 649                                    FALSE
## 787                                    FALSE
##     Party.fctr.Final.All.X...glmnet.error
## 76                            -0.07548066
## 461                            0.08997759
## 541                            0.11784572
## 608                            0.14856389
## 649                            0.17809084
## 787                            0.37630964
##     USER_ID Party.fctr Party.fctr.All.X..rcv.glmnet.prob
## 786    1538          D                         0.7193312
## 787    2495          D                         0.7964733
## 788     485          D                         0.8208562
## 789    6053          D                                NA
## 790    4350          D                                NA
## 791    3431          D                                NA
##     Party.fctr.All.X..rcv.glmnet Party.fctr.All.X..rcv.glmnet.err
## 786                            R                             TRUE
## 787                            R                             TRUE
## 788                            R                             TRUE
## 789                         <NA>                               NA
## 790                         <NA>                               NA
## 791                         <NA>                               NA
##     Party.fctr.All.X..rcv.glmnet.err.abs
## 786                            0.7193312
## 787                            0.7964733
## 788                            0.8208562
## 789                                   NA
## 790                                   NA
## 791                                   NA
##     Party.fctr.All.X..rcv.glmnet.is.acc
## 786                               FALSE
## 787                               FALSE
## 788                               FALSE
## 789                                  NA
## 790                                  NA
## 791                                  NA
##     Party.fctr.Final.All.X...glmnet.prob Party.fctr.Final.All.X...glmnet
## 786                            0.7708571                               R
## 787                            0.7763096                               R
## 788                            0.7772199                               R
## 789                            0.7987214                               R
## 790                            0.8247472                               R
## 791                            0.9109257                               R
##     Party.fctr.Final.All.X...glmnet.err
## 786                                TRUE
## 787                                TRUE
## 788                                TRUE
## 789                                TRUE
## 790                                TRUE
## 791                                TRUE
##     Party.fctr.Final.All.X...glmnet.err.abs
## 786                               0.7708571
## 787                               0.7763096
## 788                               0.7772199
## 789                               0.7987214
## 790                               0.8247472
## 791                               0.9109257
##     Party.fctr.Final.All.X...glmnet.is.acc
## 786                                  FALSE
## 787                                  FALSE
## 788                                  FALSE
## 789                                  FALSE
## 790                                  FALSE
## 791                                  FALSE
##     Party.fctr.Final.All.X...glmnet.accurate
## 786                                    FALSE
## 787                                    FALSE
## 788                                    FALSE
## 789                                    FALSE
## 790                                    FALSE
## 791                                    FALSE
##     Party.fctr.Final.All.X...glmnet.error
## 786                             0.3708571
## 787                             0.3763096
## 788                             0.3772199
## 789                             0.3987214
## 790                             0.4247472
## 791                             0.5109257

dsp_feats_vctr <- c(NULL)
for(var in grep(".imp", names(glb_feats_df), fixed=TRUE, value=TRUE))
    dsp_feats_vctr <- union(dsp_feats_vctr, 
                            glb_feats_df[!is.na(glb_feats_df[, var]), "id"])

# print(glbObsTrn[glbObsTrn$UniqueID %in% FN_OOB_ids, 
#                     grep(glb_rsp_var, names(glbObsTrn), value=TRUE)])

print(setdiff(names(glbObsTrn), names(glbObsAll)))
## [1] "Party.fctr.Final.All.X...glmnet.prob"   
## [2] "Party.fctr.Final.All.X...glmnet"        
## [3] "Party.fctr.Final.All.X...glmnet.err"    
## [4] "Party.fctr.Final.All.X...glmnet.err.abs"
## [5] "Party.fctr.Final.All.X...glmnet.is.acc"
for (col in setdiff(names(glbObsTrn), names(glbObsAll)))
    # Merge or cbind ?
    glbObsAll[glbObsAll$.src == "Train", col] <- glbObsTrn[, col]

print(setdiff(names(glbObsFit), names(glbObsAll)))
## character(0)
print(setdiff(names(glbObsOOB), names(glbObsAll)))
## character(0)
for (col in setdiff(names(glbObsOOB), names(glbObsAll)))
    # Merge or cbind ?
    glbObsAll[glbObsAll$.lcn == "OOB", col] <- glbObsOOB[, col]
    
print(setdiff(names(glbObsNew), names(glbObsAll)))
## character(0)
#glb2Sav(); all.equal(savObsAll, glbObsAll); all.equal(sav_models_lst, glb_models_lst)
#load(file = paste0(glbOut$pfx, "dsk_knitr.RData"))
#cmpCols <- names(glbObsAll)[!grepl("\\.Final\\.", names(glbObsAll))]; all.equal(savObsAll[, cmpCols], glbObsAll[, cmpCols]); all.equal(savObsAll[, "H.P.http"], glbObsAll[, "H.P.http"]); 

replay.petrisim(pn = glb_analytics_pn, 
    replay.trans = (glb_analytics_avl_objs <- c(glb_analytics_avl_objs, 
        "data.training.all.prediction","model.final")), flip_coord = TRUE)
## time trans    "bgn " "fit.data.training.all " "predict.data.new " "end " 
## 0.0000   multiple enabled transitions:  data.training.all data.new model.selected    firing:  data.training.all 
## 1.0000    1   2 1 0 0 
## 1.0000   multiple enabled transitions:  data.training.all data.new model.selected model.final data.training.all.prediction   firing:  data.new 
## 2.0000    2   1 1 1 0 
## 2.0000   multiple enabled transitions:  data.training.all data.new model.selected model.final data.training.all.prediction data.new.prediction   firing:  model.selected 
## 3.0000    3   0 2 1 0 
## 3.0000   multiple enabled transitions:  model.final data.training.all.prediction data.new.prediction     firing:  data.training.all.prediction 
## 4.0000    5   0 1 1 1 
## 4.0000   multiple enabled transitions:  model.final data.training.all.prediction data.new.prediction     firing:  model.final 
## 5.0000    4   0 0 2 1

glb_chunks_df <- myadd_chunk(glb_chunks_df, "predict.data.new", major.inc = TRUE)
##                label step_major step_minor label_minor     bgn     end
## 21 fit.data.training          9          1           1 389.605 396.092
## 22  predict.data.new         10          0           0 396.093      NA
##    elapsed
## 21   6.488
## 22      NA

Step 10.0: predict data new

## Warning in glb_get_predictions(obs_df, mdl_id = glbMdlFinId, rsp_var =
## glb_rsp_var, : Using default probability threshold: 0.4

## Warning in glb_get_predictions(obs_df, mdl_id = glbMdlFinId, rsp_var =
## glb_rsp_var, : Using default probability threshold: 0.4
## Warning in glb_analytics_diag_plots(obs_df = glbObsNew, mdl_id =
## glbMdlFinId, : Limiting important feature scatter plots to 5 out of 108
## Warning: Removed 547 rows containing missing values (geom_point).

## Warning: Removed 547 rows containing missing values (geom_point).

## Warning: Removed 547 rows containing missing values (geom_point).

## Warning: Removed 547 rows containing missing values (geom_point).

## Warning: Removed 547 rows containing missing values (geom_point).

## Warning: Removed 547 rows containing missing values (geom_point).

## Warning: Removed 547 rows containing missing values (geom_point).

## Warning: Removed 547 rows containing missing values (geom_point).

## Warning: Removed 547 rows containing missing values (geom_point).

## Warning: Removed 547 rows containing missing values (geom_point).

## NULL
## [1] "OOBobs total range outliers: 0"
## [1] "newobs total range outliers: 0"
## [1] "Stacking file Q109244No_AllXpreProc_cnk03_rest_out_fin.csv to prediction outputs..."
## [1] 0.4
## [1] "glbMdlSelId: All.X##rcv#glmnet"
## [1] "glbMdlFinId: Final.All.X###glmnet"
## [1] "Cross Validation issues:"
##        MFO###myMFO_classfr  Random###myrandom_classfr 
##                          0                          0 
## Max.cor.Y.rcv.1X1###glmnet       Final.All.X###glmnet 
##                          0                          0
##                                 max.Accuracy.OOB max.AUCROCR.OOB
## All.X##rcv#glmnet                      0.5867580       0.6153233
## Low.cor.X##rcv#glmnet                  0.5730594       0.6077246
## Interact.High.cor.Y##rcv#glmnet        0.5662100       0.5851273
## Max.cor.Y.rcv.1X1###glmnet             0.5410959       0.5584215
## Max.cor.Y##rcv#rpart                   0.5410959       0.5448590
## Random###myrandom_classfr              0.5365297       0.5042029
## MFO###myMFO_classfr                    0.5365297       0.5000000
## Final.All.X###glmnet                          NA              NA
##                                 max.AUCpROC.OOB min.elapsedtime.everything
## All.X##rcv#glmnet                     0.5683681                      7.303
## Low.cor.X##rcv#glmnet                 0.5571848                      6.595
## Interact.High.cor.Y##rcv#glmnet       0.5598575                      2.492
## Max.cor.Y.rcv.1X1###glmnet            0.5441673                      0.710
## Max.cor.Y##rcv#rpart                  0.5441673                      1.464
## Random###myrandom_classfr             0.5576145                      0.381
## MFO###myMFO_classfr                   0.5000000                      0.485
## Final.All.X###glmnet                         NA                      1.761
##                                 max.Accuracy.fit opt.prob.threshold.fit
## All.X##rcv#glmnet                      0.5689194                   0.45
## Low.cor.X##rcv#glmnet                  0.5631921                   0.45
## Interact.High.cor.Y##rcv#glmnet        0.5578465                   0.50
## Max.cor.Y.rcv.1X1###glmnet             0.5595647                   0.50
## Max.cor.Y##rcv#rpart                   0.5595647                   0.50
## Random###myrandom_classfr              0.5360825                   0.55
## MFO###myMFO_classfr                    0.5360825                   0.50
## Final.All.X###glmnet                   0.6717033                   0.50
##                                 opt.prob.threshold.OOB
## All.X##rcv#glmnet                                 0.40
## Low.cor.X##rcv#glmnet                             0.50
## Interact.High.cor.Y##rcv#glmnet                   0.50
## Max.cor.Y.rcv.1X1###glmnet                        0.50
## Max.cor.Y##rcv#rpart                              0.50
## Random###myrandom_classfr                         0.55
## MFO###myMFO_classfr                               0.50
## Final.All.X###glmnet                                NA
## [1] "All.X##rcv#glmnet OOB confusion matrix & accuracy: "
##          Prediction
## Reference   D   R
##         D 112 123
##         R  58 145
##    err.abs.fit.sum err.abs.OOB.sum err.abs.trn.sum err.abs.new.sum
## NA        737.9715        202.5673        944.8894              NA
##    .freqRatio.Fit .freqRatio.OOB .freqRatio.Tst .n.Fit .n.New.D .n.New.R
## NA              1              1              1   1746      206      341
##    .n.OOB .n.Trn.D .n.Trn.R .n.Tst .n.fit .n.new .n.trn err.abs.OOB.mean
## NA    438     1171     1013    547   1746    547   2184        0.4624824
##    err.abs.fit.mean err.abs.new.mean err.abs.trn.mean
## NA        0.4226641               NA        0.4326417
##  err.abs.fit.sum  err.abs.OOB.sum  err.abs.trn.sum  err.abs.new.sum 
##      737.9714939      202.5673105      944.8893983               NA 
##   .freqRatio.Fit   .freqRatio.OOB   .freqRatio.Tst           .n.Fit 
##        1.0000000        1.0000000        1.0000000     1746.0000000 
##         .n.New.D         .n.New.R           .n.OOB         .n.Trn.D 
##      206.0000000      341.0000000      438.0000000     1171.0000000 
##         .n.Trn.R           .n.Tst           .n.fit           .n.new 
##     1013.0000000      547.0000000     1746.0000000      547.0000000 
##           .n.trn err.abs.OOB.mean err.abs.fit.mean err.abs.new.mean 
##     2184.0000000        0.4624824        0.4226641               NA 
## err.abs.trn.mean 
##        0.4326417
## [1] "Features Importance for selected models:"
##                                 All.X..rcv.glmnet.imp
## Hhold.fctrPKy                              100.000000
## Q98197.fctrNo                               65.048286
## Q101163.fctrMom                             58.708899
## Q123464.fctrYes                             58.376542
## Q100562.fctrNo                              56.991037
## Q108950.fctrRisk-friendly                   54.825487
## Q115611.fctrYes                             54.361193
## Q113181.fctrYes                             53.879551
## Q100689.fctrYes                             51.337948
## Q98869.fctrNo                               49.757502
## Q101596.fctrYes                             48.667778
## Q116601.fctrNo                              48.168111
## Q99480.fctrYes                              45.370603
## Q120650.fctrNo                              45.127038
## Q108856.fctrSocialize                       44.049797
## Q102674.fctrYes                             42.374043
## Q98059.fctrOnly-child                       41.816050
## Q113583.fctrTunes                           40.142709
## Q122771.fctrPt                              38.593261
## YOB.Age.fctr.L                              38.504618
## Q112478.fctrNo                              37.763663
## Q115390.fctrNo                              35.851334
## Q112270.fctrYes                             34.699735
## Q102089.fctrRent                            34.328231
## Q120379.fctrYes                             33.890156
## Edn.fctr^4                                  33.474144
## YOB.Age.fctr.Q                              32.725231
## Q116441.fctrYes                             32.561349
## Q116441.fctrNo                              31.961122
## Gender.fctrM                                30.991757
## Q109367.fctrNo                              30.762719
## Q108855.fctrUmm...                          30.651230
## Q101162.fctrPessimist                       30.464319
## Q110740.fctrPC                              29.995557
## Q115899.fctrCs                              29.831009
## Q106389.fctrNo                              29.797007
## Q100010.fctrNo                              29.534982
## Q106388.fctrNo                              28.714152
## Q106389.fctrYes                             27.246625
## Q115611.fctrNo                              26.632569
## Income.fctr.C                               26.585030
## Q108342.fctrOnline                          26.519873
## Q104996.fctrNo                              25.762556
## Q120194.fctrStudy first                     25.250573
## Q102089.fctrOwn                             25.196772
## Q122120.fctrYes                             25.143277
## Q107491.fctrYes                             25.107161
## Q115195.fctrYes                             25.008801
## Q108617.fctrNo                              24.861481
## Q116797.fctrNo                              24.844391
## Edn.fctr.Q                                  24.488980
## Q112512.fctrNo                              24.132376
## Q98197.fctrYes                              23.920028
## Q99716.fctrNo                               23.154532
## Q118232.fctrPr                              23.059123
## Q98578.fctrYes                              22.695485
## Q116197.fctrP.M.                            21.745735
## Q100680.fctrNo                              21.324913
## Q115610.fctrNo                              21.267518
## Q119851.fctrNo                              20.743225
## Q110740.fctrMac                             20.432264
## Q111848.fctrNo                              20.141646
## Q98578.fctrNo                               20.027792
## Income.fctr^4                               19.965962
## Q115777.fctrEnd                             19.742700
## Q114386.fctrMysterious                      19.450401
## Q106388.fctrYes                             19.444040
## Q116601.fctrYes                             19.116540
## Q99480.fctrNo                               19.027483
## Q117186.fctrCool headed                     18.799709
## Q102674.fctrNo                              18.686343
## Q115195.fctrNo                              18.538604
## Q120472.fctrScience                         18.463879
## Q120014.fctrNo                              18.255955
## Q116448.fctrNo                              17.381505
## Q109367.fctrYes                             17.309567
## Edn.fctr^5                                  17.188696
## Q102289.fctrYes                             17.162123
## Q114961.fctrYes                             16.792500
## Q106272.fctrNo                              16.774756
## Q118117.fctrYes                             16.713073
## Q118892.fctrYes                             16.652916
## Q116953.fctrYes                             16.385513
## Q121700.fctrYes                             16.103522
## Hhold.fctrPKn                               15.645196
## YOB.Age.fctr^7                              15.506145
## Q120978.fctrYes                             15.303583
## Q120650.fctrYes                             15.292652
## Q107491.fctrNo                              15.269665
## Hhold.fctrMKy                               14.861675
## Q101162.fctrOptimist                        14.793446
## Q121699.fctrYes                             14.694718
## Q106042.fctrNo                              14.316775
## Q121011.fctrNo                              14.277880
## Edn.fctr^6                                  14.023760
## Q123621.fctrNo                              13.994117
## Q101163.fctrDad                             13.879981
## YOB.Age.fctr.C                              13.676680
## Q120012.fctrNo                              13.534430
## Edn.fctr^7                                  13.334549
## Q118232.fctrId                              12.824690
## Q101596.fctrNo                              12.592090
## Hhold.fctrSKn                               12.588092
## Q106993.fctrNo                              12.466488
## Income.fctr^6                               12.207976
## Q106272.fctrYes                             12.095670
## Q114386.fctrTMI                             12.090392
## Q116953.fctrNo                              12.044159
## Q116797.fctrYes                             11.902041
## Q115777.fctrStart                           11.562297
## Q120379.fctrNo                              11.455087
## Q116881.fctrRight                           11.317870
## Q117186.fctrHot headed                      11.149297
## Q114517.fctrNo                              11.124766
## Q108856.fctrSpace                           10.950168
## Q96024.fctrYes                              10.517245
## Q113181.fctrNo                              10.216551
## YOB.Age.fctr^8                              10.193243
## Q112270.fctrNo                              10.169781
## Q118233.fctrNo                               9.987533
## Q108342.fctrIn-person                        9.872076
## Q119334.fctrYes                              8.319375
## Q111848.fctrYes                              8.042110
## Q124122.fctrNo                               7.977838
## Q99581.fctrYes                               7.636125
## Q122770.fctrNo                               7.539847
## Q119851.fctrYes                              7.498226
## Q100689.fctrNo                               7.409099
## Q109244.fctrNA:.clusterid.fctr3              7.406972
## YOB.Age.fctr^4                               7.329632
## Gender.fctrF                                 6.851830
## YOB.Age.fctr(35,40]:YOB.Age.dff              6.719081
## Q115899.fctrMe                               6.439028
## Q107869.fctrYes                              6.347354
## Q113992.fctrYes                              5.761898
## Q114961.fctrNo                               5.642044
## Q98078.fctrNo                                3.228905
## Q118892.fctrNo                               3.161839
## Q118237.fctrNo                               2.919547
## Q122771.fctrPc                               2.845281
## Q109244.fctrNA:.clusterid.fctr2              2.093614
## Q118237.fctrYes                              0.000000
## Hhold.fctrSKy                                0.000000
## Q114152.fctrNo                               0.000000
## Q99581.fctrNo                                0.000000
## Q120194.fctrTry first                        0.000000
## Q116881.fctrHappy                            0.000000
## Q115390.fctrYes                              0.000000
##                                 Final.All.X...glmnet.imp
## Hhold.fctrPKy                                 93.7346540
## Q98197.fctrNo                                 98.4507341
## Q101163.fctrMom                              100.0000000
## Q123464.fctrYes                               56.5298106
## Q100562.fctrNo                                82.6556096
## Q108950.fctrRisk-friendly                     80.0786117
## Q115611.fctrYes                               80.9559941
## Q113181.fctrYes                               86.8448993
## Q100689.fctrYes                               63.3218547
## Q98869.fctrNo                                 79.4276036
## Q101596.fctrYes                               86.3867841
## Q116601.fctrNo                                70.6798922
## Q99480.fctrYes                                63.4513280
## Q120650.fctrNo                                63.0239655
## Q108856.fctrSocialize                         84.3051782
## Q102674.fctrYes                               71.6021843
## Q98059.fctrOnly-child                         93.7018588
## Q113583.fctrTunes                             63.0283055
## Q122771.fctrPt                                41.2926240
## YOB.Age.fctr.L                                58.3346195
## Q112478.fctrNo                                45.0756213
## Q115390.fctrNo                                57.5998105
## Q112270.fctrYes                               51.9000844
## Q102089.fctrRent                              21.9645961
## Q120379.fctrYes                               31.9004682
## Edn.fctr^4                                    47.6890300
## YOB.Age.fctr.Q                                53.5907116
## Q116441.fctrYes                               48.5994944
## Q116441.fctrNo                                33.1126008
## Gender.fctrM                                  45.1537452
## Q109367.fctrNo                                 0.3277773
## Q108855.fctrUmm...                            51.9636049
## Q101162.fctrPessimist                         10.4568764
## Q110740.fctrPC                                35.3884747
## Q115899.fctrCs                                24.5356857
## Q106389.fctrNo                                51.0346434
## Q100010.fctrNo                                40.3155171
## Q106388.fctrNo                                24.1079058
## Q106389.fctrYes                               43.5578863
## Q115611.fctrNo                                46.5857230
## Income.fctr.C                                 48.6997550
## Q108342.fctrOnline                            77.3303958
## Q104996.fctrNo                                33.9333750
## Q120194.fctrStudy first                       34.8433397
## Q102089.fctrOwn                               22.5947270
## Q122120.fctrYes                               37.9479679
## Q107491.fctrYes                               23.5709595
## Q115195.fctrYes                               21.6236755
## Q108617.fctrNo                                35.1778217
## Q116797.fctrNo                                20.4782131
## Edn.fctr.Q                                    38.3484122
## Q112512.fctrNo                                 0.0000000
## Q98197.fctrYes                                31.1929759
## Q99716.fctrNo                                 34.4747068
## Q118232.fctrPr                                37.6634569
## Q98578.fctrYes                                19.4781361
## Q116197.fctrP.M.                              34.6237317
## Q100680.fctrNo                                18.0443918
## Q115610.fctrNo                                 0.0000000
## Q119851.fctrNo                                44.0789092
## Q110740.fctrMac                               20.3357876
## Q111848.fctrNo                                 3.9686750
## Q98578.fctrNo                                 33.0330291
## Income.fctr^4                                  1.6473598
## Q115777.fctrEnd                               29.6334344
## Q114386.fctrMysterious                        13.5982125
## Q106388.fctrYes                                3.2793165
## Q116601.fctrYes                               38.4189710
## Q99480.fctrNo                                 23.0970147
## Q117186.fctrCool headed                       26.2498303
## Q102674.fctrNo                                26.7282724
## Q115195.fctrNo                                39.9600562
## Q120472.fctrScience                           26.4468022
## Q120014.fctrNo                                12.3218903
## Q116448.fctrNo                                 1.1297491
## Q109367.fctrYes                               33.5652362
## Edn.fctr^5                                     8.9649272
## Q102289.fctrYes                                5.9017171
## Q114961.fctrYes                               14.9078644
## Q106272.fctrNo                                 0.0000000
## Q118117.fctrYes                                9.8992717
## Q118892.fctrYes                               23.3747671
## Q116953.fctrYes                                4.1202631
## Q121700.fctrYes                               27.7992573
## Hhold.fctrPKn                                 56.0846195
## YOB.Age.fctr^7                                 0.0000000
## Q120978.fctrYes                                6.5340086
## Q120650.fctrYes                               34.6737468
## Q107491.fctrNo                                34.1245353
## Hhold.fctrMKy                                 12.0833409
## Q101162.fctrOptimist                          49.4906098
## Q121699.fctrYes                               31.4394825
## Q106042.fctrNo                                12.3417586
## Q121011.fctrNo                                19.6160444
## Edn.fctr^6                                     1.3519514
## Q123621.fctrNo                                21.5385623
## Q101163.fctrDad                               23.3378950
## YOB.Age.fctr.C                                 9.1065163
## Q120012.fctrNo                                15.7999237
## Edn.fctr^7                                    39.0082599
## Q118232.fctrId                                32.7133016
## Q101596.fctrNo                                24.5777070
## Hhold.fctrSKn                                 18.3727801
## Q106993.fctrNo                                16.0418684
## Income.fctr^6                                  9.4610206
## Q106272.fctrYes                               16.8186069
## Q114386.fctrTMI                               22.8130795
## Q116953.fctrNo                                10.1685057
## Q116797.fctrYes                                5.8415292
## Q115777.fctrStart                              2.8251719
## Q120379.fctrNo                                22.3715765
## Q116881.fctrRight                             15.9997800
## Q117186.fctrHot headed                        14.4774825
## Q114517.fctrNo                                17.5848980
## Q108856.fctrSpace                             12.4662045
## Q96024.fctrYes                                 0.0000000
## Q113181.fctrNo                                20.7391979
## YOB.Age.fctr^8                                16.9900374
## Q112270.fctrNo                                30.8781884
## Q118233.fctrNo                                22.3749814
## Q108342.fctrIn-person                         15.8458733
## Q119334.fctrYes                               11.0632564
## Q111848.fctrYes                               18.1967973
## Q124122.fctrNo                                23.5425712
## Q99581.fctrYes                                19.5755240
## Q122770.fctrNo                                24.0905001
## Q119851.fctrYes                               18.3184093
## Q100689.fctrNo                                20.4960918
## Q109244.fctrNA:.clusterid.fctr3               13.2351884
## YOB.Age.fctr^4                                16.7010342
## Gender.fctrF                                  11.5249916
## YOB.Age.fctr(35,40]:YOB.Age.dff               18.5076853
## Q115899.fctrMe                                13.7392945
## Q107869.fctrYes                               11.6395691
## Q113992.fctrYes                               30.3610613
## Q114961.fctrNo                                16.3616600
## Q98078.fctrNo                                 10.9883700
## Q118892.fctrNo                                12.6006743
## Q118237.fctrNo                                11.3180976
## Q122771.fctrPc                                15.5050655
## Q109244.fctrNA:.clusterid.fctr2               22.5559912
## Q118237.fctrYes                               30.0960106
## Hhold.fctrSKy                                 17.0907466
## Q114152.fctrNo                                14.5174069
## Q99581.fctrNo                                 12.1445170
## Q120194.fctrTry first                         11.5654460
## Q116881.fctrHappy                             11.2033020
## Q115390.fctrYes                               10.6450327
## [1] "glbObsNew prediction stats:"
## 
##   D   R 
## 206 341
##                   label step_major step_minor label_minor     bgn     end
## 22     predict.data.new         10          0           0 396.093 406.979
## 23 display.session.info         11          0           0 406.980      NA
##    elapsed
## 22  10.887
## 23      NA

Null Hypothesis (\(\sf{H_{0}}\)): mpg is not impacted by am_fctr.
The variance by am_fctr appears to be independent. #{r q1, cache=FALSE} # print(t.test(subset(cars_df, am_fctr == "automatic")$mpg, # subset(cars_df, am_fctr == "manual")$mpg, # var.equal=FALSE)$conf) # We reject the null hypothesis i.e. we have evidence to conclude that am_fctr impacts mpg (95% confidence). Manual transmission is better for miles per gallon versus automatic transmission.

##                        label step_major step_minor label_minor     bgn
## 2               inspect.data          2          0           0  13.274
## 13              cluster.data          5          0           0 187.380
## 16                fit.models          8          0           0 291.196
## 14   partition.data.training          6          0           0 245.044
## 3                 scrub.data          2          1           1 150.665
## 17                fit.models          8          1           1 347.340
## 22          predict.data.new         10          0           0 396.093
## 20         fit.data.training          9          0           0 380.781
## 1                import.data          1          0           0   5.750
## 18                fit.models          8          2           2 370.100
## 21         fit.data.training          9          1           1 389.605
## 19                fit.models          8          3           3 377.582
## 15           select.features          7          0           0 288.391
## 11      extract.features.end          3          6           6 185.865
## 12       manage.missing.data          4          0           0 186.754
## 9      extract.features.text          3          4           4 185.724
## 10   extract.features.string          3          5           5 185.795
## 7     extract.features.image          3          2           2 185.637
## 4             transform.data          2          2           2 185.535
## 6  extract.features.datetime          3          1           1 185.597
## 8     extract.features.price          3          3           3 185.689
## 5           extract.features          3          0           0 185.577
##        end elapsed duration
## 2  150.664 137.391  137.390
## 13 245.043  57.663   57.663
## 16 347.339  56.143   56.143
## 14 288.391  43.347   43.347
## 3  185.534  34.870   34.869
## 17 370.099  22.760   22.759
## 22 406.979  10.887   10.886
## 20 389.605   8.824    8.824
## 1   13.273   7.524    7.523
## 18 377.582   7.482    7.482
## 21 396.092   6.488    6.487
## 19 380.781   3.199    3.199
## 15 291.195   2.804    2.804
## 11 186.754   0.889    0.889
## 12 187.379   0.626    0.625
## 9  185.794   0.070    0.070
## 10 185.864   0.070    0.069
## 7  185.689   0.052    0.052
## 4  185.577   0.042    0.042
## 6  185.636   0.039    0.039
## 8  185.723   0.035    0.034
## 5  185.596   0.019    0.019
## [1] "Total Elapsed Time: 406.979 secs"